已加載 hive 表中 spark 資料框的資料。在加載 df.show(10) 之前以正確的格式和資料顯示日期列,但在查詢 hive 表日期列時顯示為空。
//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'=''
);
uj5u.com熱心網友回復:
您可以嘗試更改 DDL 以使用 serde 而不是 TxtInputFormat。
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe'
WITH SERDEPROPERTIES ('field.delim'='/u0003')
TBLPROPERTIES('serialization.null.format'='');
問題似乎在于 hive 端的存盤和檢索,而不是 spark 處理。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/383917.html
標籤:阿帕奇火花 Hadoop 蜂巢 apache-spark-sql 高品质
