本文介绍了如何从嵌套表BigQuery插入嵌套表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个嵌套表,我想彼此插入.

I have 2 Nested Tables and I want to INSERT INTO each other.

我尝试这个:

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;

这篇关于如何从嵌套表BigQuery插入嵌套表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 11:48
查看更多