Google app engine 使用Java将数据从Google云存储加载到BigQuery
我想上传数据从谷歌云存储到大查询表。 下面是我创建作业的代码:Google app engine 使用Java将数据从Google云存储加载到BigQuery,google-app-engine,google-bigquery,google-cloud-storage,Google App Engine,Google Bigquery,Google Cloud Storage,我想上传数据从谷歌云存储到大查询表。 下面是我创建作业的代码: Job job = new Job(); JobConfiguration config = new JobConfiguration(); JobConfigurationLoad loadConfig = new JobConfigurationLoad(); List<String> sources = new ArrayList<String>(); sour
Job job = new Job();
JobConfiguration config = new JobConfiguration();
JobConfigurationLoad loadConfig = new JobConfigurationLoad();
List<String> sources = new ArrayList<String>();
sources.add("gs://bucket/file.cvs");
loadConfig.setSourceUris(sources);
TableReference tableRef = new TableReference();
tableRef.setDatasetId("DATASET_ID");
tableRef.setTableId(TABLE_ID);
tableRef.setProjectId(PROJECT_ID);
loadConfig.setDestinationTable(tableRef);
List<TableFieldSchema> fields = FieldsBigQuery.schema();
TableSchema schema = new TableSchema();
schema.setFields(fields);
loadConfig.setSchema(schema);
config.setLoad(loadConfig);
job.setConfiguration(config);
Insert insert = _bigquery.jobs().insert(PROJECT_ID, job);
insert.setProjectId(PROJECT_ID);
JobReference jobRef = insert.execute().getJobReference();
Job Job=新作业();
JobConfiguration配置=新的JobConfiguration();
JobConfigurationLoadConfig=新的JobConfigurationLoad();
列表源=新的ArrayList();
添加(“gs://bucket/file.cvs”);
loadConfig.setSourceUris(源代码);
TableReference tableRef=新的TableReference();
tableRef.setDatasetId(“数据集_ID”);
tableRef.setTableId(TABLE_ID);
tableRef.setProjectId(项目ID);
loadConfig.setDestinationTable(tableRef);
List fields=FieldsBigQuery.schema();
TableSchema schema=new TableSchema();
schema.setFields(字段);
loadConfig.setSchema(模式);
config.setLoad(loadConfig);
setConfiguration(配置);
Insert Insert=\u bigquery.jobs().Insert(项目ID,作业);
插入.setProjectId(项目ID);
JobReference jobRef=insert.execute().getJobReference();
我没有任何错误或异常,但它不会将任何数据上载到我的表(表大小为0B)。我试图创建一个没有任何数据的表,然后将数据上传到此表,但事实并非如此
如果有任何帮助,我将不胜感激
非常感谢 记住使用以下工具检查作业状态:
JobStatus status =
_bigquery.jobs().get(PROJECT_ID, jobRef.getJobId()).execute().getStatus();
System.out.println(status.toPrettyString());
如果一切正常,作业状态可能处于挂起或运行状态,您必须等待作业完成。或者,您可以阅读无法运行的原因和消息。请记住检查作业状态:
JobStatus status =
_bigquery.jobs().get(PROJECT_ID, jobRef.getJobId()).execute().getStatus();
System.out.println(status.toPrettyString());
如果一切正常,作业状态可能处于挂起或运行状态,您必须等待作业完成。或者,您可以阅读无法运行的原因和消息