具有BigTable连接的BigQuery,无法执行任何查询


9

我想基于BigTable中的数据生成一些报告。为此,我想创建一个查询,该查询将从BigTable获取最新数据,并将其传递到Data Studio报告中。现在的问题是,当我在BigQuery中创建BigTable连接时,即使在空表上也无法执行任何查询。我通过以下方式为BigQuery创建类型:

bq mk \
--external_table_definition=gs://somebucket/big-table-definition.json \
datareportingdataset.datareportingtable

并且命令成功执行。我的big-table-definition.json样子如下:

{
    "sourceFormat": "BIGTABLE",
    "sourceUris": [
        "https://googleapis.com/bigtable/projects/playground-2/instances/data-reporting/tables/data-reporting-table"
    ],
    "bigtableOptions": {
        "readRowkeyAsString": "true",
        "columnFamilies" : [
            {
                "familyId": "cf1",
                "onlyReadLatest": "true",
                "columns": [
                    {
                        "qualifierString": "temp",
                        "type": "STRING"
                    },
                    {
                    //the rest of the columns
                ]
            }
        ]
    }
}

执行简单select *查询时的错误如下所示:

Error while reading table: datareportingdataset.datareportingtable, error message: Error detected while parsing row starting at position: 2. Error: Data between close double quote (") and field separator.

首先,我怀疑BigTable中有一些数据,但是当我从那里删除所有内容时,仍然会发生错误。我发现它必须与json文件本身有关,因为当我将“ sourceFormats”向下移动几行时,报告的错误更改位置。我在这里做错了什么?

Answers:


1

只是复制了您的案例并发现了完全相同的错误。在我看来,当您运行bq mk命令时,它根本不提取任何数据。

作为一种解决方法,我建议您运行数据流作业以将数据作为.avro文件提取到Cloud Storage中,然后将数据导入Bigquery中的数据集中。


我认为Bigtable Avro文件无法导入BigQuery(即使它接受Avro文件)
— Billy Jacobson

1

我想我能够重现此问题。该错误信息是混乱,但作为记录在这里:

您必须手动创建JSON模式文件,并且该文件必须在本地计算机上。不支持引用存储在Cloud Storage或Google Drive中的JSON模式文件。

我使用Bigtable快速入门进行了一些测试,对我来说效果很好:

bq query "SELECT * FROM DATASET.datareportingtable"
Waiting on JOB_ID ... (3s) Current status: DONE   
+--------+-----------------+---------------------------+-----------------------+
| rowkey | cf1_column_name | cf1_column_cell_timestamp | cf1_column_cell_value |
+--------+-----------------+---------------------------+-----------------------+
| r1     | c1              |       2019-10-15 18:15:04 | test-value            |
+--------+-----------------+---------------------------+-----------------------+

我唯一不同的是使用本地路径,如下所示:

--external_table_definition=big-table-definition.json

将此更改回:

--external_table_definition=gs://$BUCKET/big-table-definition.json

而且我遇到了同样的错误:

bq query "SELECT * FROM DATASET.datareportingtable2"
Waiting on JOB_ID ... (0s) Current status: DONE   
BigQuery error in query operation: Error processing job 'PROJECT:JOB_ID': Error while reading table: DATASET.datareportingtable2, error message: Error detected while parsing row starting at
position: 2. Error: Data between close double quote (") and field separator.

有趣的是,我现在没有时间检查一下,但是感谢您的努力
— Kris
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.