Sql BigQuery-创建视图时,如何更改嵌套列模式的顺序?
我想更改视图上嵌套的模式 但是BigQuery不会这样做,因为我将记录称为“productPrice” 事实上,如果我不调用它,我就不能将它嵌套在我的视图中 使用“productPrice”时出现错误消息 表2Sql BigQuery-创建视图时,如何更改嵌套列模式的顺序?,sql,google-bigquery,spring-cloud-gcp-bigquery,Sql,Google Bigquery,Spring Cloud Gcp Bigquery,我想更改视图上嵌套的模式 但是BigQuery不会这样做,因为我将记录称为“productPrice” 事实上,如果我不调用它,我就不能将它嵌套在我的视图中 使用“productPrice”时出现错误消息 表2 productPrice RECORD NULLABLE productPrice.taxRate FLOAT NULLABLE productPrice.taxType STRING
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
要求提供产品价格
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]
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
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
无产品价格的请求
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]
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
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
下面是BigQuery标准SQL
#standardSQL
SELECT
STRUCT(
productPrice.taxRate,
productPrice.taxType,
productPrice.priceStartDate,
productPrice.currency,
productPrice.price,
productPrice.type
) AS productPrice
FROM table1
UNION ALL
SELECT
STRUCT(
productPrice.taxRate,
productPrice.taxType,
productPrice.priceStartDate,
productPrice.currency,
productPrice.price,
productPrice.type
)
FROM table2