opensourcegeek
opensourcegeek

Reputation: 5962

How to create standard SQL tables in bigquery

I just checked the web UI, to create an empty table all the data types exposed are legacy SQL data types. I then checked out bq mk and I cannot see any option to set the standard SQL flag.

Even weird thing is if I create a table using standard SQL data types,

bq mk --schema name:string,value:int64 -t test.newtable5
Table 'oandmpoc:test.newtable5' successfully created.

It creates a table with value INTEGER, I'll dig around later to see how ARRAY and STRUCT data types behave. Is there anything obvious I'm missing?

Upvotes: 1

Views: 570

Answers (1)

Tim Swena
Tim Swena

Reputation: 14776

BigQuery does not store tables differently for legacy SQL versus standard SQL. INTEGER is the legacy SQL alias for the INT64 type. Likewise, RECORD is an alias for STRUCT. You'll notice that the legacy SQL data types reference has entries for DATE, TIME, and DATETIME even though these are most useful from standard SQL.

More info about about which legacy SQL types map to which standard SQL types is available on the migrating from legacy SQL documentation page.

Upvotes: 1

Related Questions