문제

Google 클라우드 스토리지에서 BigQuery로 데이터를 업로드하고 싶지만이 작업을 수행하는 방법을 설명하는 Java 샘플 코드를 찾을 수 없습니다.누군가 가이 일을하는 방법으로 힌트를 주겠 니?

실제로 할 일은 Google App Engine 테이블에서 BigQuery로 데이터를 전송하는 것입니다 (매일 일상적으로 일상적으로 동기화 할 수 있습니다.Google App 엔진의 Google Cloud Storage 서비스를 사용하여 Google 클라우드 스토리지의 파일에 파일에 쓰기 (New) 레코드를 사용하며 누락 된 부분은 BigQuery의 테이블에 데이터를 추가하거나 처음 쓰기를 위해 새 테이블을 만듭니다.)BigQuery 브라우저 도구를 사용하여 데이터를 수동으로 업로드 / 추가 할 수는 있지만, 자동으로 데이터를 추가 할 수 있습니다. 그렇지 않으면 매일 수동으로 수행해야합니다.

도움이 되었습니까?

해결책

Google 클라우드 스토리지에서 BigQuery에 테이블을로드하기위한 Java 샘플을 알지 못합니다.즉, 쿼리 작업을 실행하는 지침을 따르면 여기 를 실행할 수 있습니다.Folowing이 대신로드 작업 :

Job job = new Job();
JobConfiguration config = new JobConfiguration();
JobConfigurationLoad loadConfig = new JobConfigurationLoad();
config.setLoad(loadConfig);

job.setConfiguration(config);

// Set where you are importing from (i.e. the Google Cloud Storage paths).
List<String> sources = new ArrayList<String>();
sources.add("gs://bucket/csv_to_load.csv");
loadConfig.setSourceUris(sources);

// Describe the resulting table you are importing to:
TableReference tableRef = new TableReference();
tableRef.setDatasetId("myDataset");
tableRef.setTableId("myTable");
tableRef.setProjectId(projectId);
loadConfig.setDestinationTable(tableRef);

List<TableFieldSchema> fields = new ArrayList<TableFieldSchema>();
TableFieldSchema fieldFoo = new TableFieldSchema();
fieldFoo.setName("foo");
fieldFoo.setType("string");
TableFieldSchema fieldBar = new TableFieldSchema();
fieldBar.setName("bar");
fieldBar.setType("integer");
fields.add(fieldFoo);
fields.add(fieldBar);
TableSchema schema = new TableSchema();
schema.setFields(fields);
loadConfig.setSchema(schema);

// Also set custom delimiter or header rows to skip here....
// [not shown].

Insert insert = bigquery.jobs().insert(projectId, job);
insert.setProjectId(projectId);
JobReference jobRef =  insert.execute().getJobReference();

// ... see rest of codelab for waiting for job to complete.
.

로드 구성 개체에 대한 자세한 내용은 Javadoc 여기 .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top