执行 DDL 以根据 GCS 上存储的文件在 BigQuery 中创建本机表

问题描述 投票:0回答:1

我想从带有 DDL 语句的 CSV 文件在 BigQuery 中创建一个本机表,其方式复制 BigQuery UI 中的“从...创建表”功能,如下面的屏幕截图所示:

我的最终目标是在 Dataform sqlx 文件中使用查询。

当我尝试使用 CREATE TABLE 语句执行此操作时,它失败并出现错误

Unknown option: format

CREATE TABLE `dataset_name.table_name` (
field1 STRING,
field2 STRING
) 

OPTIONS(format = 'CSV',
uris = ['gs://path/to/file.csv'],
field_delimiter = ',',
skip_leading_rows=1);

虽然下面的查询工作正常......

CREATE EXTERNAL TABLE `dataset_name.table_name` (
field1 STRING,
field2 STRING
) 

OPTIONS(format = 'CSV',
uris = ['gs://path/to/file.csv'],
field_delimiter = ',',
skip_leading_rows=1);

...但会抛出有关禁用缓存的警告消息

这只是启用元数据缓存的问题还是我错过了其他东西?

谢谢您的帮助!

google-cloud-platform google-bigquery ddl external-tables
1个回答
0
投票

您没有使用正确的 SQL 函数。您必须按照

文档
中的说明使用 LOAD DATA

© www.soinside.com 2019 - 2024. All rights reserved.