2016-10-24 23 views
2

https://cloud.google.com/bigquery/docs/creating-partitioned-tablesは、Pythonでパーティションテーブルを作成する方法を示しています。私はそこにいた、私はそれをやった。Javaでパーティション化されたBigQueryテーブルを作成する方法

ここで問題は、Java APIで同じことをする方法ですか?

{ 
    "tableReference": { 
    "projectId": "myProject", 
    "tableId": "table1", 
    "datasetId": "mydataset" 
    }, 
    "timePartitioning": { 
    "type": "DAY" 
    } 
} 

Javaの行方不明のパーティションを持つ::com.google.apis:google-api-services-bigquery:v2-rev326-1.22.0:私はMavenの中央リポジトリから最新バージョンのAPIを使用してい

Job createTableJob = new Job(); 
JobConfiguration jobConfiguration = new JobConfiguration(); 
JobConfigurationLoad loadConfiguration = new JobConfigurationLoad(); 

createTableJob.setConfiguration(jobConfiguration); 
jobConfiguration.setLoad(loadConfiguration); 

TableReference tableReference = new TableReference() 
    .setProjectId("myProject") 
    .setDatasetId("mydataset") 
    .setTableId("table1"); 

loadConfiguration.setDestinationTable(tableReference); 
// what should be place here to set DAY timePartitioning? 

以下のPython 1と同じことをやって、対応するJavaコードとは何ですか。

答えて

2

https://cloud.google.com/bigquery/docs/reference/v2/tables/insert https://cloud.google.com/bigquery/docs/reference/v2/tables#resource

例のJavaコード:

String projectId = ""; 
String datasetId = ""; 

Table content = new Table(); 
TimePartitioning timePartitioning = new TimePartitioning(); 
timePartitioning.setType("DAY"); 
timePartitioning.setExpirationMs(1L); 
content.setTimePartitioning(timePartitioning); 

Bigquery.Tables.Insert request = bigquery.tables().insert(projectId, datasetId, content); 
Table response = request.execute(); 
0

私は(のJava API 0.32で動作します)パーティション表を作成するためのより多くの更新方法を共有させてください:

Schema schema = Schema.of(newFields); 
TimePartitioning timePartitioning = TimePartitioning.of(TimePartitioning.Type.DAY); 
TableDefinition tableDefinition = StandardTableDefinition.newBuilder() 
     .setSchema(schema) 
     .setTimePartitioning(timePartitioning) 
     .build(); 

TableId tableId = TableId.of(projectName, datasetName, tableName) 
TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build(); 
bigQuery.create(tableInfo); 
関連する問題