Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery: Create table statement with struct

What is the syntax for creating table statement with struct fields? Below doesn't seem to work. I want to create a Record field such as id.level1.level2.level3.

CREATE TABLE mayumi_load_test.struct_cre(
STRUCT<STRUCT<STRUCT<STRUCT<id INT64> level1> level2>level3,
  t_ TIMESTAMP
)
PARTITION BY Date(t_)
like image 922
user_1357 Avatar asked Oct 19 '25 10:10

user_1357


1 Answers

Below is for BigQuery Standard SQL

Create Table

#standardSQL
CREATE TABLE mayumi_load_test.struct_cre (
  id STRUCT<level1 STRUCT<level2 STRUCT<level3 INT64>>>,
  t_ TIMESTAMP
)
PARTITION BY DATE(t_)   

Insert Data

#standardSQL
INSERT INTO mayumi_load_test.struct_cre(id, t_) 
  VALUES(
    STRUCT(STRUCT(STRUCT(777))),
    CURRENT_TIMESTAMP()
  )
like image 180
Mikhail Berlyant Avatar answered Oct 21 '25 00:10

Mikhail Berlyant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!