def jobs_insert_query(self, sql, table_name=None, append=False,
                        overwrite=False, dry_run=False, use_cache=True, batch=True,
                        allow_large_results=False, table_definitions=None, query_params=None):
    """Issues a request to insert a query job.

    Args:
      sql: the SQL string representing the query to execute.
      table_name: None for an anonymous table, or a name parts tuple for a long-lived table.
      append: if True, append to the table if it is non-empty; else the request will fail if table
          is non-empty unless overwrite is True.
      overwrite: if the table already exists, truncate it instead of appending or raising an
          Exception.
      dry_run: whether to actually execute the query or just dry run it.
      use_cache: whether to use past query results or ignore cache. Has no effect if destination is
          specified.
      batch: whether to run this as a batch job (lower priority) or as an interactive job (high
          priority, more expensive).
      allow_large_results: whether to allow large results (slower with some restrictions but
          can handle big jobs).
      table_definitions: a dictionary of ExternalDataSource names and objects for any external
          tables referenced in the query.
      query_params: a dictionary containing query parameter types and values, passed to BigQuery.
    Returns:
      A parsed result object.
    Raises:
      Exception if there is an error performing the operation.
    """
    url = Api._ENDPOINT + (Api._JOBS_PATH % (self.project_id, ''))

    data = {
        'kind': 'bigquery#job',
        'configuration': {
            'query': {
                'query': sql,
                'useQueryCache': use_cache,
                'allowLargeResults': allow_large_results,
                'useLegacySql': False
            },
            'dryRun': dry_run,
            'priority': 'BATCH' if batch else 'INTERACTIVE',
        },
    }

    query_config = data['configuration']['query']

    if table_definitions:
      expanded_definitions = {}
      for td in table_definitions:
        expanded_definitions[td] = table_definitions[td]._to_query_json()
      query_config['tableDefinitions'] = expanded_definitions

    if table_name:
      query_config['destinationTable'] = {
          'projectId': table_name.project_id,
          'datasetId': table_name.dataset_id,
          'tableId': table_name.table_id
      }
      if append:
        query_config['writeDisposition'] = "WRITE_APPEND"
      elif overwrite:
        query_config['writeDisposition'] = "WRITE_TRUNCATE"

    if self.bigquery_billing_tier:
        query_config['maximumBillingTier'] = self.bigquery_billing_tier

    if query_params:
      query_config['queryParameters'] = query_params

    return google.datalab.utils.Http.request(url, data=data, credentials=self.credentials)
Issues a request to insert a query job.

    Args:
      sql: the SQL string representing the query to execute.
      table_name: None for an anonymous table, or a name parts tuple for a long-lived table.
      append: if True, append to the table if it is non-empty; else the request will fail if table
          is non-empty unless overwrite is True.
      overwrite: if the table already exists, truncate it instead of appending or raising an
          Exception.
      dry_run: whether to actually execute the query or just dry run it.
      use_cache: whether to use past query results or ignore cache. Has no effect if destination is
          specified.
      batch: whether to run this as a batch job (lower priority) or as an interactive job (high
          priority, more expensive).
      allow_large_results: whether to allow large results (slower with some restrictions but
          can handle big jobs).
      table_definitions: a dictionary of ExternalDataSource names and objects for any external
          tables referenced in the query.
      query_params: a dictionary containing query parameter types and values, passed to BigQuery.
    Returns:
      A parsed result object.
    Raises:
      Exception if there is an error performing the operation.