[英]GCP - BigTable to BigQuery
我正在尝试使用外部表配置在 BigQuery 中查询 Bigtable 数据。 我正在使用以下 SQL 命令。 但是,我收到一条错误消息,指出invalid bigtable_options for format CLOUD_BIGTABLE.
当我删除columns
字段时,代码有效。 对于上下文,原始数据如下所示(运行没有列字段的查询):
行键 | aAA.column.name | aAA.column.cell.value |
---|---|---|
4271 | xxx | 30 |
yyy | 25 |
但我希望表格看起来像这样:
行键 | xxx |
---|---|
4271 | 30 |
CREATE EXTERNAL TABLE dev_test.telem_test
OPTIONS (
format = 'CLOUD_BIGTABLE',
uris = ['https://googleapis.com/bigtable/projects/telem/instances/dbb-bigtable/tables/db1'],
bigtable_options =
"""
{
bigtableColumnFamilies: [
{
"familyId": "aAA",
"type": "string",
"encoding": "string",
"columns": [
{
"qualifierEncoded": string,
"qualifierString": string,
"fieldName": "xxx",
"type": string,
"encoding": string,
"onlyReadLatest": false
}
]
}
],
readRowkeyAsString: true
}
"""
);
我想你让每个列属性的默认值。 string
是要提供的值的类型,但不是要提供的原始值。 这里的JSON是没有意义的。 尝试像那样添加双引号
CREATE EXTERNAL TABLE dev_test.telem_test
OPTIONS (
format = 'CLOUD_BIGTABLE',
uris = ['https://googleapis.com/bigtable/projects/telem/instances/dbb-bigtable/tables/db1'],
bigtable_options =
"""
{
bigtableColumnFamilies: [
{
"familyId": "aAA",
"type": "string",
"encoding": "string",
"columns": [
{
"qualifierEncoded": "string",
"qualifierString": "string",
"fieldName": "xxx",
"type": "string",
"encoding": "string",
"onlyReadLatest": false
}
]
}
],
readRowkeyAsString: true
}
"""
);
false 是正确的,因为类型是 boolean。 此处有更多详细信息。 编码“字符串”将是错误的(使用真实的编码类型)。
这里的错误是在这部分:
bigtableColumnFamilies: [
它应该是:
"columnFamilies": [
关于为字符串添加列,您只会添加:
"columns": [{
"qualifierString": "name_of_column_from_bt",
"fieldName": "if_i_want_rename",
}],
字段名称不是必需的。 但是,要访问您的字段值,您仍然必须使用这样的 SQL 代码:
SELECT
aAA.xxx.cell.value as xxx
FROM dev_test.telem_test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.