@Internal public class BigqueryClient extends java.lang.Object
Example:
Get a new Bigquery client:
[
BigqueryClient client = BigqueryClient.getNewBigqueryClient(applicationName);
]
Execute a query with retries:
[
QueryResponse response = client.queryWithRetries(queryString, projectId);
]
Create a new dataset in one project:
[
client.createNewDataset(projectId, datasetId);
]
Delete a dataset in one project, included its all tables:
[
client.deleteDataset(projectId, datasetId);
]
Create a new table
[
client.createNewTable(projectId, datasetId, newTable)
]
Insert data into table
[
client.insertDataToTable(projectId, datasetId, tableName, rows)
]
Constructor and Description |
---|
BigqueryClient(java.lang.String applicationName) |
Modifier and Type | Method and Description |
---|---|
void |
createNewDataset(java.lang.String projectId,
java.lang.String datasetId)
Creates a new dataset.
|
void |
createNewDataset(java.lang.String projectId,
java.lang.String datasetId,
@Nullable java.lang.Long defaultTableExpirationMs)
Creates a new dataset with defaultTableExpirationMs.
|
void |
createNewTable(java.lang.String projectId,
java.lang.String datasetId,
Table newTable) |
void |
deleteDataset(java.lang.String projectId,
java.lang.String datasetId) |
void |
deleteTable(java.lang.String projectId,
java.lang.String datasetId,
java.lang.String tableName) |
static BigqueryClient |
getClient(java.lang.String applicationName) |
static Bigquery |
getNewBigqueryClient(java.lang.String applicationName) |
Table |
getTableResource(java.lang.String projectId,
java.lang.String datasetId,
java.lang.String tableId) |
void |
insertDataToTable(java.lang.String projectId,
java.lang.String datasetId,
java.lang.String tableName,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows)
Inserts rows to a table using a BigQuery streaming write.
|
java.util.List<TableRow> |
queryUnflattened(java.lang.String query,
java.lang.String projectId,
boolean typed,
boolean useStandardSql)
Performs a query without flattening results.
|
QueryResponse |
queryWithRetries(java.lang.String query,
java.lang.String projectId) |
QueryResponse |
queryWithRetries(java.lang.String query,
java.lang.String projectId,
boolean typed) |
QueryResponse |
queryWithRetriesUsingStandardSql(java.lang.String query,
java.lang.String projectId) |
public static Bigquery getNewBigqueryClient(java.lang.String applicationName)
public static BigqueryClient getClient(java.lang.String applicationName)
@Nonnull public QueryResponse queryWithRetries(java.lang.String query, java.lang.String projectId) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
@Nonnull public QueryResponse queryWithRetriesUsingStandardSql(java.lang.String query, java.lang.String projectId) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
@Nonnull public java.util.List<TableRow> queryUnflattened(java.lang.String query, java.lang.String projectId, boolean typed, boolean useStandardSql) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
@Nonnull public QueryResponse queryWithRetries(java.lang.String query, java.lang.String projectId, boolean typed) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void createNewDataset(java.lang.String projectId, java.lang.String datasetId) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void createNewDataset(java.lang.String projectId, java.lang.String datasetId, @Nullable java.lang.Long defaultTableExpirationMs) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void deleteTable(java.lang.String projectId, java.lang.String datasetId, java.lang.String tableName)
public void deleteDataset(java.lang.String projectId, java.lang.String datasetId)
public void createNewTable(java.lang.String projectId, java.lang.String datasetId, Table newTable) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void insertDataToTable(java.lang.String projectId, java.lang.String datasetId, java.lang.String tableName, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> rows) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public Table getTableResource(java.lang.String projectId, java.lang.String datasetId, java.lang.String tableId) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException