BigQueryApi (BigQuery APIs)

createTable

Create a new table in the data set identified by a table name and its schema.​

BigQueryApi.createTable(datasetName, tableName, schema)

or

BigQueryApi.createTable(datasetName, tableName, classAttrs)

or

BigQueryApi.createTable(datasetName, tableName,
      csvSchema, classAttrs, mappings)

parameters:

datasetName: dataset name (string)
tableName:   table name (string)
schema:       schema object (string)
classAttrs:   class attributes (List of dictionaries)
csvSchema:     csv representation object (List of dictionaries)
mappings:     mappings object (List of dictionaries)

Return : result

A Result object indicating the success or failure of the table creation operation.

getBQDataSets

Get the list of all dataset names.​

BigQueryApi.getBQDataSets()

parameters:

none​

Return:

A Result object containing the list of BigQuery datasets.

getBQTables

List the tables in a specific data set.​

BigQueryApi.getBQTables(datasetName)

parameters:

datasetName: name of the data set (string)

Return:

A Result object containing the list of tables within the specified dataset.

getTable

Retrieves table information from the data set.​

BigQueryApi.getTable(datasetName, tableName) 
or
BigQueryApi.getTable(datasetAndTableName)

parameters:

datasetName:  name of the data set (string)
tableName:    name of the table (string)
datasetAndTableName: (string)

Return:

A Result object containing information about the specified table.

getTableFields

Retrieve field information for a table from BigQuery.

BigQueryApi.getTableFields(datasetAndTableName)
or
BigQueryApi.getTableFields(datasetName, tableName)

Parameters

datasetAndTableName: (string)
datasetName: (string)
tableName: (string)

Returns

A Result object containing field information for the specified table.

executeQuery

Executes a query in a specific data set and return the results.​

BigQueryApi.executeQuery(queryString)

parameters:

queryString: query (string)

Return:

A Result object containing the query execution result.

getBigQueryIterator

Get an iterator over table query.

BigQueryApi.getBigQueryIterator(query, startIndex, pageSize)

parameters:

query:      table query (string)
startIndex: index start (int)
pageSize:    page size (int)

Return:

A Result object containing the BigQuery iterator.

insertRows

Insert a list of rows into the table.​

BigQueryApi.insertRows(
      datasetName, tableName, list)

parameters:

datasetName:   dataset name (string)
tableName:     table in the data set (string)
list:          records to be inserted (List of dictionaries)

Return:

A Result object indicating the success or failure of the insert operation.

importCSVIntoTable

Import data from CSV file to the dataset table​. The header in the CSV file can be skipped if needed.

BigQueryApi.importCSVIntoTable(datasetName, tableName, pathToFile, 
      csvSchema, classAttrs, mappings, numberOfRowsToSkip)
      
or

BigQueryApi.importCSVIntoTable(datasetName, tableName, pathToFile, schema, numberOfRowsToSkip)

or

BigQueryApi.importCSVIntoTable(datasetName, tableName, path, fileName, schema, numberOfRowsToSkip)

parameters:

datasetName:   name of the dataset (string)
tableName:     name of the table in the data set (string)
pathToFile:    absolute path to the file on the system (string)
csvSchema:     the csv schema (List of dictionaries)
classAttrs:    attributes (List of dictionaries)
mappings:      mapping of attributes with schema (List of dictionaries)
numberOfRowsToSkip:   if skipping rows from the top of the csv file (int)
fileName:      the name of the file (string)
schema:         the schema (Dictionary)

Return:

A Result object indicating the success or failure of the import operation.

importCSVbyURIIntoTable

Same as above but using the URI for CSV file location.​

BigQueryApi.importCSVbyURIIntoTable(datasetName, tableName, sourceUri, schema, numberOfRowsToSkip)

parameters:

datasetName:     name of the data set (string)
tableName:       name of the table in the dataset (string)
sourceUri:       the uri of source file (string)
schema:           the scheme of the csv (Dictionary)
numberOfRowsToSkip:   csv line to skip from the start

Return:

A Result object indicating the success or failure of the import operation.

exportTableToCSV

Exports dataset table into a CSV file.​

BigQueryApi.exportTableToCSV(
      datasetName,
      tableName,
      pathToFile)
or

BigQueryApi.exportTableToCSV(
      datasetName,
      tableName,
      Stringath, fileName)

parameters:

datasetName:   name of the data set (string)
tableName:     name of the table in the data set (string)
pathToFile:    path to the CSV file (string)
path:          same as above (string)
fileName:      name of the file (string)

Return:

A Result object indicating the success or failure of the export operation.

exportTableToCSVByURI

Same as above but using the URI for the csv file location

BigQueryApi.exportTableToCSVByURI(
      datasetName,
      tableName,
      destinationUri)

parameters:

datasetName:   name of the data set (string)
tableName:     name of the table in the data set (string)
destinationUri:   the destination uri of csv file (string)

Return:

A Result object indicating the success or failure of the export operation.

exportTable

Export a table​ of the dataset to a file type with the destination uri provided.

BigQueryApi.exportTable(
      datasetName,
      tableName,
      destinationUri,
      dataFormat)

parameters:

datasetName:   name of the dataset (string)
tableName:     name of the table in the dataset (string)
destinationUri:   destination uri (string)
dataFormat:    format of the exported data (string)

Return:

A Result object indicating the success or failure of the export operation.

bigQueryToCSV

export data set table with specific columns to a CSV.​

BigQueryApi.bigQueryToCSV(filePath, columnNames, dataSetName, bqTableName,
      query) 
or


BigQueryApi.bigQueryToCSV(filePath, columnNames, dataSetName, bqTableName,
        query, functionName)

parameters:

filePath:       the path of the CSV file (string)
columnNames:    table column names (list of strings)
dataSetName:    name of the data set (string)
bqTableName:    name of table (string)
query:          query to run (string)
functionName:   extra function to be called (string)

Return:

A Result object indicating the success or failure of the export operation.

getpage

Retrieve a page of data from BigQuery.

BigQueryApi.getPage(query, start, size)

Parameters

query (string)
start (int)
size (int)

Returns

A Result object containing the requested page of data.

createTableFromCSV

Create table from CSV

BigQueryApi.createTableFromCSV(datasetName, tableName, bucketFileName)
or
BigQueryApi.createTableFromCSV(datasetName, tableName, bucketName, bucketFileName)

Parameters

datasetName (string)
tableName (string)
bucketFileName (string)
bucketName (string)

Returns

A Result object indicating the success or failure of the table creation operation.

importJSONbyURIIntoTable

import JSON by URI into table

BigQueryApi.importJSONbyURIIntoTable(datasetName, tableName,
                                               sourceUri)
or 
BigQueryApi.importJSONbyURIIntoTable(datasetName, tableName,
                                                sourceUri, schema)

Parameters

datasetName (string)
tableName (string)
sourceUri (string)
schema (list)

Returns

A Result object indicating the success or failure of the import operation.

bigQueryToCSVWithScript

Export data from BigQuery to a CSV file using a custom script.

BigQueryApi.bigQueryToCSVWithScript(filePath, columnNames,
      dataSetName, bqTableName, query, script, scriptFlavor)

Parameters

filePath (string)
columnNames (list of strings)
dataSetName (string)
bqTableName (string)
query (string)
script (string)
scriptFlavor (string)

Returns

An integer indicating the success or failure of the export operation.

Last updated