Google BigQuery 支持 Avro 逻辑类型

Google BigQuery support for Avro logicalTypes

正如 Google 声称的那样,不支持从 Avro logicalType 到 BigQuery 特定类型的转换(如 here on the bottom 所述)。

但是我能够使用以下架构加载 Avro 文件:

schema = {
    'name': 'test',
    'namespace': 'testing',
    'type': 'record',
    'fields': [
        {'name': 'test_timestamp', 'type': 'long', 'logicalType': 'timestamp-millis'},
    ],
}

使用 TIMESTAMP.

类型列的 BigQuery

情况与以下架构不同:

schema = {
    'name': 'test',
    'namespace': 'testing',
    'type': 'record',
    'fields': [
        {'name': 'testdate', 'type': 'int', 'logicalType': 'date'},
    ],
} 

和 BigQuery table,列类型为 DATE。我通过以下方式使用 bq load(在两种情况下):

bq --location=EU load --source_format=AVRO --project_id=test-project dataset.table "gs://bucket/test_file.avro"

失败并出现异常:

Field testdate has changed type from DATE to INTEGER

BigQuery 是否有可能支持 logicalTypes,或者是否有任何优雅的方法来解决这种情况? (我知道使用临时 table 的解决方法然后有 BQL select 将 TIMESTAMPS 转换为 DATES 但它不是很漂亮 :P)

对 Avro 逻辑类型的原生理解现已公开供所有 BigQuery 用户使用。有关详细信息,请参阅此处的文档页面:https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-avro#logical_types