simbo1905
simbo1905

Reputation: 6822

Cannot define a BigQuery column as ARRAY<STRUCT<INT64, INT64>>

I am trying to define a table that has a column that is an arrays of structs using standard sql. The docs here suggest this should work:

CREATE OR REPLACE TABLE ta_producer_conformed.FundStaticData
(
  id STRING,
  something ARRAY<STRUCT<INT64,INT64>>
)

but I get an error:

$ bq query --use_legacy_sql=false --location=asia-east2  "$(cat xxxx.ddl.temp.sql |   awk 'ORS=" "')"
Waiting on bqjob_r6735048b_00000173ed2d9645_1 ... (0s) Current status: DONE
Error in query string: Error processing job 'xxxxx-10843454-yyyyy-
dev:bqjob_r6735048b_00000173ed2d9645_1': Illegal field name:

Changing the field (edit: column!) name does not fix it. What I am doing wrong?

Upvotes: 0

Views: 1557

Answers (1)

simbo1905
simbo1905

Reputation: 6822

The fields within the struct need to be named so this works:

CREATE OR REPLACE TABLE ta_producer_conformed.FundStaticData
(
  id STRING,
  something ARRAY<STRUCT<x INT64,y INT64>>
)

Upvotes: 4

Related Questions