我有以下SQL:
#standardSql
CREATE OR REPLACE TABLE batch_report
(
date DATE,
memberId STRING OPTIONS(description="xxxx member ID"),
variables ARRAY<STRUCT<
id STRING,
datatype STRING,
effectiveDate TIMESTAMP,
values ARRAY<STRUCT<
id STRING,
value STRING
>
>,
isSensitive BOOLEAN,
name STRING
>
>
)
PARTITION BY date
OPTIONS (
partition_expiration_days=62, -- two months
description="Stores the raw response from the xxxx batch endpoint"
)
使用bq query --dataset=dev < create_batch_report.sql
通过CLI运行此命令时,会显示以下错误消息:
Incompatible table partitioning specification. Expected partitioning specification none, but input partitioning specification is
interval(type:day,field:date)
但是,在BigQuery控制台中运行它并在CREATE OR REPLACE TABLE
语句中提供数据集名称时,它将正确执行。这是一个错误,如果可以的话,我该如何解决?
答案 0 :(得分:0)
通过CLI运行时,我修改了第一行以包含数据集,而不是使用dataset
标志将其传递。这导致它正确执行。我已将SQL修改为:
#standardSql
CREATE OR REPLACE TABLE {ENVIRONMENT}.batch_report
(
date DATE,
memberId STRING OPTIONS(description="xxxx member ID"),
variables ARRAY<STRUCT<
id STRING,
datatype STRING,
effectiveDate TIMESTAMP,
values ARRAY<STRUCT<
id STRING,
value STRING
>
>,
isSensitive BOOLEAN,
name STRING
>
>
)
PARTITION BY date
OPTIONS (
partition_expiration_days=62, -- two months
description="Stores the raw response from the xxxx batch endpoint"
)
并通过CLI使用以下命令执行它:
sed s/"{ENVIRONMENT}"/${ENVIRONMENT}/g create_batch_report.sql | \
bq query