Плагин Maven avro выдает схему, пока не поддерживается ошибка - PullRequest
1 голос
/ 21 апреля 2020

В моем проекте maven я использую плагин maven avro для создания Java классов из файлов схемы avro. Это файл avro, который я получил из реестра схемы.

{
   "type":"record",
   "name":"Envelope",
   "namespace":"mongodb.company.price_service_company_calc_logs",
   "fields":[
      {
         "name":"after",
         "type":[
            null,
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"patch",
         "type":[
            null,
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"filter",
         "type":[
            null,
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"source",
         "type":{
            "type":"record",
            "name":"Source",
            "namespace":"io.debezium.connector.mongo",
            "fields":[
               {
                  "name":"version",
                  "type":"string"
               },
               {
                  "name":"connector",
                  "type":"string"
               },
               {
                  "name":"name",
                  "type":"string"
               },
               {
                  "name":"ts_ms",
                  "type":"long"
               },
               {
                  "name":"snapshot",
                  "type":[
                     {
                        "type":"string",
                        "connect.version":1,
                        "connect.parameters":{
                           "allowed":true,
                           "last":false
                        },
                        "connect.default":false,
                        "connect.name":"io.debezium.data.Enum"
                     },
                     null
                  ],
                  "default":false
               },
               {
                  "name":"db",
                  "type":"string"
               },
               {
                  "name":"rs",
                  "type":"string"
               },
               {
                  "name":"collection",
                  "type":"string"
               },
               {
                  "name":"ord",
                  "type":"int"
               },
               {
                  "name":"h",
                  "type":[
                     null,
                     "long"
                  ],
                  "default":null
               },
               {
                  "name":"tord",
                  "type":[
                     null,
                     "long"
                  ],
                  "default":null
               }
            ],
            "connect.name":"io.debezium.connector.mongo.Source"
         }
      },
      {
         "name":"op",
         "type":[
            null,
            "string"
         ],
         "default":null
      },
      {
         "name":"ts_ms",
         "type":[
            null,
            "long"
         ],
         "default":null
      }
   ],
   "connect.name":"mongodb.company.price_service_company_calc_logs.Envelope"
}

Каждый раз, когда я запускаю пакет mvn, он выдает следующую ошибку:

Выполнение по умолчанию для цели org. apache .avro: avro-maven-plugin: 1.9.2: сбой схемы: схема еще не поддерживается: null

Можно ли получить дополнительную информацию о точной root проблемы? Очевидно, что параметры maven -e или -X мало помогают.

1 Ответ

0 голосов
/ 21 апреля 2020

Оказалось, файл avro не правильный. Все нулевые значения для типов должны быть в двойных кавычках.

{
   "type":"record",
   "name":"Envelope",
   "namespace":"mongodb.company.price_service_company_calc_logs",
   "fields":[
      {
         "name":"after",
         "type":[
            "null",
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"patch",
         "type":[
            "null",
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"filter",
         "type":[
            "null",
            {
               "type":"string",
               "connect.version":1,
               "connect.name":"io.debezium.data.Json"
            }
         ],
         "default":null
      },
      {
         "name":"source",
         "type":{
            "type":"record",
            "name":"Source",
            "namespace":"io.debezium.connector.mongo",
            "fields":[
               {
                  "name":"version",
                  "type":"string"
               },
               {
                  "name":"connector",
                  "type":"string"
               },
               {
                  "name":"name",
                  "type":"string"
               },
               {
                  "name":"ts_ms",
                  "type":"long"
               },
               {
                  "name":"snapshot",
                  "type":[
                     {
                        "type":"string",
                        "connect.version":1,
                        "connect.parameters":{
                           "allowed":true,
                           "last":false
                        },
                        "connect.default":false,
                        "connect.name":"io.debezium.data.Enum"
                     },
                     "null"
                  ],
                  "default":false
               },
               {
                  "name":"db",
                  "type":"string"
               },
               {
                  "name":"rs",
                  "type":"string"
               },
               {
                  "name":"collection",
                  "type":"string"
               },
               {
                  "name":"ord",
                  "type":"int"
               },
               {
                  "name":"h",
                  "type":[
                     "null",
                     "long"
                  ],
                  "default":null
               },
               {
                  "name":"tord",
                  "type":[
                     "null",
                     "long"
                  ],
                  "default":null
               }
            ],
            "connect.name":"io.debezium.connector.mongo.Source"
         }
      },
      {
         "name":"op",
         "type":[
            "null",
            "string"
         ],
         "default":null
      },
      {
         "name":"ts_ms",
         "type":[
            "null",
            "long"
         ],
         "default":null
      }
   ],
   "connect.name":"mongodb.company.price_service_company_calc_logs.Envelope"
}
...