简体   繁体   中英

Creating BigQuery table column with BIGNUMERIC data type using Java

When creating BigQuery tables using the Java com.google.cloud:google-cloud-bigquery library, I don't see the BIGNUMERIC column data-type in the StandardSQLTypeName enumerations. I see NUMERIC but not BIGNUMERIC . How would I create a table with a BIGNUMERIC column programmatically? Thanks!

  Field f1 = Field.newBuilder("first_name", StandardSQLTypeName.STRING).build();
  Field f2 = Field.newBuilder("score", StandardSQLTypeName.NUMERIC).build();
  Schema schema = Schema.of(Arrays.asList(f1,f2));

  TableId tableId = TableId.of("my_data_set", "tbl_people"));
  TableDefinition tableDefinition = StandardTableDefinition.of(schema);
  TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();

  bigQuery.create(tableInfo);

If you're using versions 1.124.7 and below, the enum for StandardSQLTypeName.BIGNUMERIC is not yet present. I suggest you use the latest version ( 1.125.0 and up).

You can refer to this doc for a detailed guide on how to create and use BigQuery table.

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