当前位置: 首页>>代码示例>>Java>>正文


Java Table.setTableReference方法代码示例

本文整理汇总了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();
}
 
开发者ID:apache,项目名称:beam,代码行数:27,代码来源:BigQueryServicesImplTest.java

示例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;
	}
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:21,代码来源:AnalyticsService.java

示例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();
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:43,代码来源:BigQueryHelper.java


注:本文中的com.google.api.services.bigquery.model.Table.setTableReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。