google-bigquery - Bigquery dbt_external_tables 外部数据配置
问题描述
在使用 dbt_external_tables 包时我需要一些帮助。
我意识到在我在 GCS 中的 csv 中,有些行似乎有换行符,这在尝试查询由宏创建的表时会导致一些问题。
有时,手动配置外部表时,BigQuery UI 有两个选项: 允许锯齿状行 (CSV) 允许带引号的换行符 (CSV) true 我通常将这些选项设置为 true,有时问题就解决了。我不知道如何使用 dbt_external_tables 来做到这一点。
这很重要,因为我在尝试查询 dbt 创建的表时收到此错误“读取表时出错:kpi-process.file_csv.History,错误消息:CSV 表引用列位置 9,但从位置开始的行:10956 包含只有 7 列。”
解决方案
该dbt-external-tables
包支持传递BigQuery 外部表的字典,该字典映射到options
此处记录的选项。在您的情况下,听起来您想打开allow_jagged_rows
and allow_quoted_newlines
,因此您可以像这样指定它们:
version: 2
sources:
- name: my_external_source
tables:
- name: my_external_table
location: 'gs://bucket/path/*'
options:
format: csv
allow_jagged_rows: true
allow_quoted_newlines: true
并且 dbt 将相应地模板化 DDL 语句:
create or replace external statement my_external_source.my_external_table
options (
format = 'csv',
allow_jagged_rows = true,
allow_quoted_newlines = true,
uris = ['gs://bucket/path/*']
)
推荐阅读
- promise - 如何将 http.get.("URL").subscribe 转换为承诺,以便我可以等待它?
- amazon-s3 - 为什么在从对象存储系统上传或下载时需要立即验证校验和?
- reactjs - 如何在 React.js 中将箭头函数转换为类
- python - Python RE搜索方法pyschools T12 Q10
- android - 当条件为真时,颤振重定向到新屏幕
- python - 如何将重复的列表元素解析为数据框
- amazon-web-services - consul 用 consul 平衡跨区域的流量
- json - 在 PySpark 中写入数据帧的自定义文件名
- nestjs - NestJS 中的环境变量在每个模块中都不可见?
- javascript - 是否可以使用组合键或上下文菜单运行 Tampermonkey 脚本?