查询数据时 Hive 日期列显示为空

Hive date column shows null while querying the data

已在 hive 中加载 spark 数据帧的数据 table。 在加载之前 df.show(10) 以正确的格式和数据显示日期列,但在查询配置单元时 table 日期列显示为空。

//Spark Code
df.show(10)
+----------+
|    bus_dt|
+----------+
|2021-12-01|
+----------+

//Hive shell
select distinct bus_dt from stg.dateTable;
NULL

//Table
create table stg.dateTable (
`bus_dt` date comment 'from deserializer')
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '/u0003'
STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
TBLPROPERTIES (
'serialization.null.format'=''
);

您能否尝试更改 DDL 以使用 serde 而不是 TxtInputFormat。

ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe'
WITH SERDEPROPERTIES ('field.delim'='/u0003')
TBLPROPERTIES('serialization.null.format'='');

问题似乎出在配置单元端的存储和检索上,而不是火花处理上。