bittu
bittu

Reputation: 1

How to create DDL for arrays of arrays in BigQuery

I am trying to create a table definition in BigQuery which can be used to insert records containing array of arrays

sample data for array of arrays: [["1","2","3","4"],["1","2","3","4"],["1","2","3","4"]]

I tried following -

CREATE TABLE IF NOT EXISTS dataset.test1 (
  a String,
  b STRUCT <STRUCT <c ARRAY <ARRAY <STRING>>>>
)

But getting following error : Array of arrays are not supported

How do I create a table structure for array of arrays records?

Upvotes: 0

Views: 1357

Answers (1)

Yun Zhang
Yun Zhang

Reputation: 5503

Array of array is not supported, the best that you can do is to have outer ARRAY of a STRUCT, then the STRUCT has an inner array field, try this SQL:

create table yourDataset.t (arrayOfArray ARRAY< STRUCT< arr ARRAY<STRING> > >)
AS SELECT  [Struct<ARRAY<STRING>>(["1","2","3","4"]),
            Struct<ARRAY<STRING>>(["1","2","3","4"]),
            Struct<ARRAY<STRING>>(["1","2","3","4"])];

Upvotes: 1

Related Questions