从具有嵌套结构的内部配置单元表读取时发生avrotypeexception

pdkcd3nj  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(331)

我在3.6版本的azurehdinsight集群上工作。它使用HortonWorksHDP2.6,这是Hive2.1.0(在Tez0.8.4上)附带的。
我有一些内部配置单元表,其中嵌套的结构字段以avro格式存储。下面是create语句的一个示例:

  1. CREATE TABLE my_example_table(
  2. some_field STRING,
  3. some_other_field STRING,
  4. some_struct struct<field1: BIGINT, inner_struct struct<field2: STRING, field3: STRING>>)
  5. PARTITIONED BY (year INT, month INT)
  6. STORED AS AVRO;

我用一个外部表填充这些表,该表也存储为avro,如下所示:

  1. INSERT INTO TABLE my_example_table
  2. PARTITION (year, month)
  3. SELECT ....
  4. FROM my_external_table;

当我想查询内部表时,出现以下错误: Failed with exception java.io.IOException:org.apache.avro.AvroTypeException: Found core.record_0, expecting union 我用avro工具从其中一个内部表中提取了avro模式,并认识到hive从我定义的结构创建联合类型:

  1. {
  2. "type" : "record",
  3. "name" : "my_example_table",
  4. "namespace" : "my_namespace",
  5. "fields" : [ {
  6. "name" : "some_field",
  7. "type" : [ "null", "string" ],
  8. "default" : null
  9. }, {
  10. "name" : "some_other_field",
  11. "type" : [ "null", "string" ],
  12. "default" : null
  13. }, {
  14. "name" : "my_struct",
  15. "type" : [ "null", {
  16. "type" : "record",
  17. "name" : "record_0",
  18. "namespace" : "",
  19. "doc" : "struct<field1: BIGINT, struct<field2: STRING, field3: STRING>>",
  20. "fields" : [ {
  21. "name" : "field1",
  22. "type" : [ "null", "long" ],
  23. "doc" : "bigint",
  24. "default" : null
  25. }, {
  26. "name" : "inner_struct",
  27. "type" : [ "null", {
  28. "type" : "record",
  29. "name" : "record_2",
  30. "namespace" : "",
  31. "doc" : "struct<field2: STRING, field3: STRING>",
  32. "fields" : [ {
  33. "name" : "field2",
  34. "type" : [ "null", "string" ],
  35. "doc" : "bigint",
  36. "default" : null
  37. }, {
  38. "name" : "field2",
  39. "type" : [ "null", "long" ],
  40. "doc" : "bigint",
  41. "default" : null
  42. }]
  43. }
  44. ]}
  45. ]}
  46. ]}
  47. }

这里怎么了?我很确定这在几天前确实有效,所以我猜测微软为hdinsight clusters换了另一个补丁版本hdp,它有另一个avro或hive版本,但我没有发现任何迹象。
我发现这个:https://issues.apache.org/jira/browse/hive-15316 这似乎是非常类似的问题(在同一个Hive版本)。
有人知道这里出了什么问题,我能做些什么来解决这个问题或作为一个解决办法吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题