使用dbt_external_tables执行外部表时提示未选中外部源的问题排查
解决dbt_external_tables提示"No external sources selected"的问题
1. 修复sources配置文件的语法缩进错误
你的ext_stage_source.yml中,external字段下的location和file_format未正确缩进,导致dbt无法识别这些外部表配置。修改后的配置如下:
version: 2 sources: - name: external_s3_stage database: test_conn schema: public loader: snowflake # 适配Snowflake适配器,原配置的S3是存储位置而非加载器类型 tables: - name: tbl_s3_stage ext_full_refresh: true description: This is the first external table created as stage from dbt. external: # 子属性需缩进,确保属于external节点 location: "s3://bucket/data/" file_format: > (TYPE = CSV FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1 TRIM_SPACE = TRUE ESCAPE_UNENCLOSED_FIELD = NONE FIELD_DELIMITER = ',') columns: - name: id data_type: varchar - name: name data_type: varchar
2. 修正运行命令的参数格式
当前命令的引号格式可能导致参数解析异常,改用JSON格式传递参数:
dbt run-operation stage_external_sources --args '{"select": "external_s3_stage.tbl_s3_stage"}'
3. 确认dbt_project.yml的sources扫描配置
确保dbt能扫描到你的sources配置文件,在dbt_project.yml中添加或确认以下配置(替换<你的项目名>为实际项目名):
sources: <你的项目名>: staging: +enabled: true +schema: public
4. 验证sources加载状态
运行dbt source list命令,检查是否能列出external_s3_stage.tbl_s3_stage。如果能正常列出,说明配置已被正确识别。
内容的提问来源于stack exchange,提问作者Sr Jefers
相关产品推荐
相关产品推荐

