我正在尝试使用 Dataform 在 BigQuery 数据集
table1
中创建两个 BigQuery 表 table2
和 SILVER
。我的目录结构如下所示:
definitions
├── source
│ └── table1_raw.sqlx
└── silver
├── table1_stg.sqlx
└── table2_stg.sqlx
table2_stg.sqlx
是 引用 table1_stg
使用 FROM ${ref("table1_stg")}
,但是,我收到编译错误 Not found: table PROJECT:SILVER.table1_stg was not found in location us-east1
。
如何确保
table1_stg.sqlx
在table2_stg.sqlx
之前运行以防止下游依赖错误?
我尝试使用
resolve()
而不是 ref()
并在配置中显式声明上游表,如
config {
type: "table",
name: "table2_stg",
dependencies: ["table1_stg"]
}
...
但收到相同的错误。
我知道可以使用 type: "operations"
从标准 SQL 创建
referenceable_output_table,但是,这似乎违背了使用
type: "table"
的目的。
您的配置看起来不错,但编译时不会运行依赖项,它们只会作为手动执行或工作流执行的一部分运行。回想一下,编译步骤只是根据 .sqlx 规范 (SQL+JS) 为您构建 SQL 查询。该查询仍然需要执行。请参阅此处了解手动执行文件的信息。
要修复编译错误,您需要执行
table1_stg.sqlx
查询,以便它实际在 BigQuery 中具体化。
将来执行
table2_stg.sqlx
查询时,如果手动运行或在工作流程中运行,您可以选择“包含依赖项”。