google-bigquery - 如何从嵌套表 BigQuery 在嵌套表中插入数据
问题描述
我有 2 个嵌套表,我想互相插入。
我试试这个:
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;
推荐阅读
- python - python 3.9.5 中的诅咒在哪里?
- r - 我想检查其对应行的每个单元格中是否存在像 ABCD 这样的字符串。如果不存在,则应返回 NA
- reactjs - CheckBox 值始终返回 true
- r - 如何在 RMarkdown 中将此表移动到左侧?
- c++ - C++ 类菜单和控制器
- javascript - 反转“order_successful”,尽管发送了参数,但没有找到任何参数。DJANGO
- android - 预打包的数据库具有无效的架构列顺序
- c# - 表格标题单元格有一条分隔线,其他标题不会改变它们的高度
- ansible - 如何使用正则表达式从字典中的字符串中提取值并将其附加到字典中?
- java - 投射对象以限制杰克逊序列化中序列化的数据