【问题标题】:How to set hive.serialization.extend.nesting.levels property to true in spark?如何在 spark 中将 hive.serialization.extend.nesting.levels 属性设置为 true?
【发布时间】:2017-06-06 00:37:01
【问题描述】:

我正在尝试将 json 转换为数据框,创建临时表并执行一些查询。但是我得到了 org.apache.hadoop.hive.serde2.SerDeException 因为 json 有超过 7 个嵌套级别。我尝试将该属性设置为 true hiveContext.sql("hive.serialization.extend.nesting.levels","true") 但仍然遇到同样的问题。我使用的是火花 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.

谢谢

【问题讨论】:

标签: json apache-spark hive apache-spark-sql


【解决方案1】:

如果外部表定义如下:

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 层的嵌套。

然后在下一步中,将表格展平为,

 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
 ;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 2021-09-28
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    相关资源
    最近更新 更多