in case of orc data reader schema passed by hive are all small cases and if
the column name stored in the file has any uppercase, it will return null
values for those columns even if the data is present in the file.
Column name matching while schema evolution should be case unaware.
we need to pass config for same from hive. the
config(orc.schema.evolution.case.sensitive) in orc will be exposed by
https://issues.apache.org/jira/browse/ORC-264
上述问题摘录自https://www.mail-archive.com/issues@hive.apache.org/msg99436.html
简单描述下上面英文描述的问题就是 在hive2.x版本以后orc格式的表,写入时候如果orc的schema 有的字段是大写,那么hive在读取schema时候,这个字段就会被读成null,所以建议设置参数
如图所示:
查看orc的schema
hive --orcfiledump oss://day=20191220/hour=03/part-00000-aaef271c-dabf-49fb-9899-2960bad0a341-c000.snappy.orc
查
如图:
orc.schema.evolution.case.sensitive
但是具体怎么设置,网上中英文都找不到案例
于是自作主张如下设置
hive --hiveconf orc.schema.evolution.case.sensitive
结果不行
又如下设置
hive --hiveconf orc.schema.evolution.case.sensitive=true
结果还是不行
发现在写入orc文件的时候
dataframe的schema是大小写,导致无法识别元数据,知道是这个原因,那就好解决了
直接schema的列名用 tolowerCase 强转成小写,问题就迎刃而解了
修改完后的orc文件用
hive --orcfiledump oss://gateway/t_dsp_bid_detail_tbl/day=20191220/hour=04/part-00000-aaef271c-dabf-49fb-9899-2960bad0a341-c000.snappy.orc
查看结果如下:
查询 就不会出现null列了
如图: