0

我正在尝试从 AVRO 文件创建一个 BQ 表。运行 BQ 加载作业时出现此错误:

“读取数据时出错,错误消息:Apache Avro 库无法解析标头并出现以下错误:默认值的类型异常。预期为长,但发现为空:空”

AVRO 文件的架构是:

{
  "type" : "record",
  "name" : "Pair",
  "namespace" : "org.apache.avro.mapred",
  "fields" : [ {
    "name" : "key",
    "type" : "int",
    "doc" : ""
  }, {
    "name" : "value",
    "type" : {
      "type" : "record",
      "name" : "CustomerInventoryOrderItems",
      "namespace" : "com.test.customer.order",
      "fields" : [ {
        "name" : "updated_at",
        "type" : "long"
      }, {
        "name" : "inventory_order_items",
        "type" : {
          "type" : "map",
          "values" : {
            "type" : "array",
            "items" : {
              "type" : "record",
              "name" : "CustomerInventoryOrderItem",
              "fields" : [ {
                "name" : "order_item_id",
                "type" : "int",
                "default" : null
              }, {
                "name" : "updated_at",
                "type" : "long"
              }, {
                "name" : "created_at",
                "type" : "long"
              }, {
                "name" : "product_id",
                "type" : [ "null", "int" ],
                "default" : null
              }, {
                "name" : "type_id",
                "type" : "int",
                "default" : null
              }, {
                "name" : "event_id",
                "type" : [ "null", "int" ],
                "default" : null
              }, {
                "name" : "price",
                "type" : [ "null", "double" ],
                "default" : null
              }, {
                "name" : "tags",
                "type" : [ "null", "string" ],
                "default" : null
              }, {
                "name" : "estimated_ship_date",
                "type" : [ "null", "long" ],
                "default" : null
              } ]
            }
          }
        }
      } ]
    },
    "doc" : "",
    "order" : "ignore"
  } ]
}

我不确定架构或其他任何问题有什么问题,因此我无法加载数据。

4

1 回答 1

1

问题很可能是具有类型int但您将null其作为默认值的字段。例如:

                "name" : "type_id",
                "type" : "int",
                "default" : null

默认值应更改为整数或类型应更改为包含的联合null(与许多其他字段一样)。

于 2021-03-06T01:21:10.003 回答