我有两个嵌套表,我想互相插入。
我试试这个:
INSERT INTO table1 ( record.id, record.product.type, record.product.price )
SELECT
id
product.type
product.price
FROM table 2
或者这个:
INSERT INTO table1 ( record.id, record.product )
VALUES (
STRUCT((select id from table2)),
STRUCT((select product.type from table2))
)
BQ警报:
Syntax error: Expected ")" or "," but got "." at [1:62] Learn More about BigQuery SQL Functions.
但不起作用。。
表1
record RECORD NULLABLE
record.id STRING NULLABLE
record.product RECORD NULLABLE
record.product.type STRING NULLABLE
record.product.price FLOAT NULLABLE
表2
id STRING NULLABLE
product RECORD NULLABLE
product.type STRING NULLABLE
product.price FLOAT NULLABLE
怎么能做到呢?
你可以试试这个:
INSERT INTO table1
SELECT STRUCT(id, STRUCT(productPrice.type, productPrice.price)) FROM table2;
您可以使用APPLY运算符来取消透视表请访问这个答案https://stackoverflow.com/a/27708046/1862306