BigQueryApi (BigQuery APIs)
createTable
Create a new table in the data set identified by a table name and its schema.
BigQueryApi.createTable(String datasetName, String tableName, Schema schema)
or
BigQueryApi.createTable(String datasetName, String tableName, List<Map<String, Object>> classAttrs)
or
BigQueryApi.createTable(String datasetName, String tableName,
List<Map<String, Object>> csvSchema, List<Map<String, Object>> classAttrs, List<Map<String, Object>> mappings)parameters:
datasetName: dataset name
tableName: table name
schema: schema object
classAttrs: class attributes
csvSchema: csv representation object
mappings: mappings objectReturn : result
the result objectgetBQDataSets
Get the list of all dataset names.
BigQueryApi.getBQDataSets()parameters:
noneReturn:
list of objectsgetBQTables
List the tables in a specific data set.
BigQueryApi.getBQTables(String datasetName)parameters:
datasetName: name of the data setReturn:
the list of the tablesgetTable
Retrieves table information from the data set.
BigQueryApi.getTable(String datasetName, String tableName)
or
BigQueryApi.getTable(String datasetAndTableName)parameters:
datasetName: name of the data set
tableName: name of the table
datasetAndTableNameReturn:
detail information of the tablegetTableFields
// Description //
BigQueryApi.getTableFields(String datasetAndTableName)
or
BigQueryApi.getTableFields(String datasetName, String tableName)Parameters
datasetAndTableName
datasetName
tableNameReturns
List<Object>executeQuery
Executes a query in a specific data set and return the results.
BigQueryApi.executeQuery(String queryString)parameters:
queryString: queryReturn:
the result object representing the query outcome.getBigQueryIterator
Get an iterator over table query.
BigQueryApi.getBigQueryIterator(String query, int startIndex, int pageSize)parameters:
query: table query
startIndex: index start
pageSize: page sizeReturn:
iterator objectinsertRows
Insert a list of rows into the table.
BigQueryApi.insertRows(
String datasetName, String tableName, List<Map<String, Object>> list)parameters:
datasetName: dataset name
tableName: table in the data set
list: records to be insertedReturn:
the result of the insertionimportCSVIntoTable
Import data from CSV file to the dataset table. The header in the CSV file can be skipped if needed.
BigQueryApi.importCSVIntoTable(String datasetName, String tableName, String pathToFile,
List<Map<String, Object>> csvSchema, List<Map<String, Object>> classAttrs, List<Map<String, Object>> mappings, int numberOfRowsToSkip)
or
BigQueryApi.importCSVIntoTable(String datasetName, String tableName, String pathToFile, Schema schema, int numberOfRowsToSkip)
or
BigQueryApi.importCSVIntoTable(String datasetName, String tableName, String path, String fileName, Schema schema, int numberOfRowsToSkip)parameters:
datasetName: name of the dataset
tableName: name of the table in the data set
pathToFile: absolute path to the file on the system
csvSchema: the csv schema
classAttrs: attributes
mappings: mapping of attributes with schema
numberOfRowsToSkip: if skipping rows from the top of the csv file
fileName: the name of the file
schema: the schemaReturn:
the result of the operationimportCSVbyURIIntoTable
Same as above but using the URI for CSV file location.
BigQueryApi.importCSVbyURIIntoTable(String datasetName, String tableName, String sourceUri, Schema schema, int numberOfRowsToSkip)parameters:
datasetName: name of the data set
tableName: name of the table in the dataset
sourceUri: the uri of source file
schema: the scheme of the csv
numberOfRowsToSkip: csv line to skip from the startReturn:
result of the operationexportTableToCSV
Exports dataset table into a CSV file.
BigQueryApi.exportTableToCSV(
String datasetName,
String tableName,
String pathToFile)
or
BigQueryApi.exportTableToCSV(
String datasetName,
String tableName,
String path, String fileName)parameters:
datasetName: name of the data set
tableName: name of the table in the data set
pathToFile: path to the CSV file
path: same as above
fileName: name of the fileReturn:
the result of the operationexportTableToCSVByURI
Same as above but using the URI for the csv file location
BigQueryApi.exportTableToCSVByURI(
String datasetName,
String tableName,
String destinationUri)parameters:
datasetName: name of the data set
tableName: name of the table in the data set
destinationUri: the destination uri of csv fileReturn:
the result of the operationexportTable
Export a table of the dataset to a file type with the destination uri provided.
BigQueryApi.exportTable(
String datasetName,
String tableName,
String destinationUri,
String dataFormat)parameters:
datasetName: name of the dataset
tableName: name of the table in the dataset
destinationUri: destination uri
dataFormat: format of the exported dataReturn:
result of the operationbigQueryToCSV
export data set table with specific columns to a CSV.
BigQueryApi.bigQueryToCSV(String filePath, String[] columnNames, String dataSetName, String bqTableName,
String query)
or
BigQueryApi.bigQueryToCSV(String filePath, String[] columnNames, String dataSetName, String bqTableName,
String query, String functionName)parameters:
filePath: the path of the CSV file
columnNames: table column names
dataSetName: name of the data set
bqTableName: name of table
query: query to run
functionName: extra function to be calledReturn:
the result of the operationgetpage
Get page details
BigQueryApi.getPage(String query, long start, long size)Parameters
query
start
sizeReturns
ObjectcreateTableFromCSV
Create table from CSV
BigQueryApi.createTableFromCSV(String datasetName, String tableName, String bucketFileName)
or
BigQueryApi.createTableFromCSV(String datasetName, String tableName, String bucketName, String bucketFileName)Parameters
datasetName
tableName
bucketFileName
bucketNameReturns
ResultimportJSONbyURIIntoTable
import JSON by URI into table
BigQueryApi.importJSONbyURIIntoTable(String datasetName, String tableName,
String sourceUri)
or
BigQueryApi.importJSONbyURIIntoTable(String datasetName, String tableName,
String sourceUri, Schema schema)Parameters
datasetName
tableName
sourceUri
schemaReturns
ResultbigQueryToCSVWithScript
Get page details
BigQueryApi.bigQueryToCSVWithScript(String filePath, String[] columnNames,
String dataSetName, String bqTableName, String query, String script, String scriptFlavor)Parameters
filePath
columnNames
dataSetName
bqTableName
query
script
scriptFlavorReturns
intLast updated
Was this helpful?