简体   繁体   中英

How to create a view in the Java BigQuery API?

使用Google BigQuery的Java客户端库,如何创建视图?

The relevant API call is tables.insert . With the Java API, this is represented by the create method on the BigQuery service object . You first have to create a TableInfo , which encapsulates a ViewDefinition object. The documentation for setDefinition on TableInfo.Builder says:

Sets the table definition. Use StandardTableDefinition to create simple BigQuery table. Use ViewDefinition to create a BigQuery view. Use ExternalTableDefinition to create a BigQuery a table backed by external data.

Sample code:

bigQuery.create(TableInfo.of(TableId.of("DatasetName", "ViewName"),
        ViewDefinition.of("SELECT this, is, the, view FROM query")))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM