如何在spark中将hive.serialization.extend.nesting.levels属性设置为true?

epfja78i  于 2021-06-28  发布在  Hive
关注(0)|答案(1)|浏览(483)

我正在尝试将json转换为dataframe,创建并执行一些查询。但是我得到org.apache.hadoop.hive.serde2.serdeexception,因为json有7个以上的嵌套级别。我试着把那个属性设置为真 hiveContext.sql("hive.serialization.extend.nesting.levels","true") 但还是有同样的问题。我使用的是spark 1.6.1版本。解决这个问题的任何帮助都是有帮助的。
添加日志 ERROR log: error in initSerDe: org.apache.hadoop.hive.serde2.SerDeException Number of levels of nesting supported for LazySimpleSerde is 7 Unable to work with level 9. Use hive.serialization.extend.nesting.levels serde property for tables using LazySimpleSerde. org.apache.hadoop.hive.serde2.SerDeException: Number of levels of nesting supported for LazySimpleSerde is 7 Unable to work with level 9. Use hive.serialization.extend.nesting.levels serde property for tables using LazySimpleSerde. 谢谢

8i9zcol2

8i9zcol21#

如果外部表定义如下:

create external table t1
(
 a int,
 b double,
 c array<struct<
          k1:struct<
                     p1:struct<
                              r1:struct<
                                        h1:struct<
                                                  s1:array<struct<
                                                                  j1:struct<
                                                                            x1:int
                                                                           >
                                                        >>
                                              >
                                     >
                            >
                    >
         >>

 )
 ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
 WITH SERDEPROPERTIES ( "mapping.time_stamp" = "timestamp" ) 
 LOCATION '/user/user1/staging/data/populationdata'
  ;

假设数据包含大于7的嵌套级别。
然后在下一步,把table弄平,

create table t1
 ROW FORMAT SERDE   'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' 
 WITH SERDEPROPERTIES ( 'hive.serialization.extend.nesting.levels'='true' )
 as
 select
   a, 
   b, 
   c1.k1
 from 
   t1
 lateral view explode(c) subview as c1
 ;

相关问题