我想更改嵌套在我的 VIEW 中的架构。
但 BigQuery 不会这样做,因为我将记录称为“productPrice”。
确实,如果我不调用它,我就无法将它嵌套在我的视图中。
使用“productPrice”时出现错误消息
Column xx in UNION ALL has incompatible types: STRUCT<type STRING, price DOUBLE, currency STRING, ...>, STRUCT<taxRate DOUBLE, taxType STRING, priceStartDate STRING, ...> at [xx:x]
表格1
productPrice RECORD NULLABLE
productPrice.type STRING NULLABLE
productPrice.price FLOAT NULLABLE
productPrice.currency STRING NULLABLE
productPrice.priceStartDate STRING NULLABLE
productPrice.taxRate FLOAT NULLABLE
productPrice.taxType STRING NULLABLE
表2
productPrice RECORD NULLABLE
productPrice.taxRate FLOAT NULLABLE
productPrice.taxType STRING NULLABLE
productPrice.priceStartDate STRING NULLABLE
productPrice.currency STRING NULLABLE
productPrice.price FLOAT NULLABLE
productPrice.type STRING NULLABLE
请求 productPrice
CREATE VIEW product_view AS
SELECT
productPrice,
productPrice.taxRate,
productPrice.taxType,
productPrice.priceStartDate,
productPrice.currency,
productPrice.price,
productPrice.type,
from table1
UNION ALL
SELECT
productPrice,
productPrice.taxRate,
productPrice.taxType,
productPrice.priceStartDate,
productPrice.currency,
productPrice.price,
productPrice.type,
FROM table2
要求没有 productPrice
CREATE VIEW product_view AS
SELECT
--productPrice,
productPrice.taxRate,
productPrice.taxType,
productPrice.priceStartDate,
productPrice.currency,
productPrice.price,
productPrice.type,
from table1
UNION ALL
SELECT
--productPrice,
productPrice.taxRate,
productPrice.taxType,
productPrice.priceStartDate,
productPrice.currency,
productPrice.price,
productPrice.type,
FROM table2
视图中没有“productPrice”的结果
type STRING NULLABLE
taxRate FLOAT NULLABLE
taxType STRING NULLABLE
priceStartDate STRING NULLABLE
currency STRING NULLABLE
price FLOAT NULLABLE