本文整理汇总了Java中com.google.api.services.bigquery.model.Table.setTableReference方法的典型用法代码示例。如果您正苦于以下问题:Java Table.setTableReference方法的具体用法?Java Table.setTableReference怎么用?Java Table.setTableReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.bigquery.model.Table
的用法示例。
在下文中一共展示了Table.setTableReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetTableSucceeds
import com.google.api.services.bigquery.model.Table; //导入方法依赖的package包/类
@Test
public void testGetTableSucceeds() throws Exception {
TableReference tableRef = new TableReference()
.setProjectId("projectId")
.setDatasetId("datasetId")
.setTableId("tableId");
Table testTable = new Table();
testTable.setTableReference(tableRef);
when(response.getContentType()).thenReturn(Json.MEDIA_TYPE);
when(response.getStatusCode()).thenReturn(403).thenReturn(200);
when(response.getContent())
.thenReturn(toStream(errorWithReasonAndStatus("rateLimitExceeded", 403)))
.thenReturn(toStream(testTable));
BigQueryServicesImpl.DatasetServiceImpl datasetService =
new BigQueryServicesImpl.DatasetServiceImpl(bigquery, PipelineOptionsFactory.create());
Table table = datasetService.getTable(tableRef, BackOff.ZERO_BACKOFF, Sleeper.DEFAULT);
assertEquals(testTable, table);
verify(response, times(2)).getStatusCode();
verify(response, times(2)).getContent();
verify(response, times(2)).getContentType();
}
示例2: createTable
import com.google.api.services.bigquery.model.Table; //导入方法依赖的package包/类
public void createTable(String datasetName, String tableName, List<TableFieldSchema> schemaFields) throws GeneralSecurityException, IOException {
Bigquery bigquery = GoogleServices.getBigqueryServiceDomainWide();
TableSchema schema = new TableSchema();
schema.setFields(schemaFields);
Table table = new Table();
table.setSchema(schema);
TableReference tableRef = new TableReference();
tableRef.setDatasetId(datasetName);
tableRef.setProjectId(AppHelper.getAppId());
tableRef.setTableId(tableName);
table.setTableReference(tableRef);
try {
bigquery.tables().insert(AppHelper.getAppId(), datasetName, table).execute();
} catch (GoogleJsonResponseException ex) {
if (ex.getStatusCode() != 409) throw ex;
}
}
示例3: importFederatedFromGcs
import com.google.api.services.bigquery.model.Table; //导入方法依赖的package包/类
/**
* Performs a federated import on data from GCS into BigQuery via a table insert.
*
* @param projectId the project on whose behalf to perform the load.
* @param tableRef the reference to the destination table.
* @param schema the schema of the source data to populate the destination table by.
* @param sourceFormat the file format of the source data.
* @param gcsPaths the location of the source data in GCS.
* @throws IOException
*/
public void importFederatedFromGcs(
String projectId,
TableReference tableRef,
@Nullable TableSchema schema,
BigQueryFileFormat sourceFormat,
List<String> gcsPaths)
throws IOException {
LOG.info(
"Importing into federated table '{}' from {} paths; path[0] is '{}'",
BigQueryStrings.toString(tableRef),
gcsPaths.size(),
gcsPaths.isEmpty() ? "(empty)" : gcsPaths.get(0));
ExternalDataConfiguration externalConf = new ExternalDataConfiguration();
externalConf.setSchema(schema);
externalConf.setSourceUris(gcsPaths);
externalConf.setSourceFormat(sourceFormat.getFormatIdentifier());
// Auto detect the schema if we're not given one, otherwise use the passed schema.
if (schema == null) {
LOG.info("No federated import schema provided, auto detecting schema.");
externalConf.setAutodetect(true);
} else {
LOG.info("Using provided federated import schema '{}'.", schema.toString());
}
Table table = new Table();
table.setTableReference(tableRef);
table.setExternalDataConfiguration(externalConf);
service.tables().insert(projectId, tableRef.getDatasetId(), table).execute();
}