【发布时间】:2020-08-14 05:28:31
【问题描述】:
我正在尝试在 ORC 文件上创建外部 Hive 表。
用于创建表的查询:
create external table fact_scanv_dly_stg (
store_nbr int,
geo_region_cd char(2),
scan_id int,
scan_type char(2),
debt_nbr string,
mds_fam_id string,
upc_nbr string,
sales_unit_qty string,
sales_amt string,
cost_amt string,
visit_dt string,
rtn_amt string,
crncy_cd string,
op_cmpny_cd string)
STORED AS ORC
location 'hdfs:///my/location/scanv_data/';
ORC 文件的架构细节(取自 DataFrame Spark-SQL):
|-- _col0: integer (nullable = true)
|-- _col1: string (nullable = true)
|-- _col2: integer (nullable = true)
|-- _col3: byte (nullable = true)
|-- _col4: short (nullable = true)
|-- _col5: integer (nullable = true)
|-- _col6: decimal(18,0) (nullable = true)
|-- _col7: decimal(9,2) (nullable = true)
|-- _col8: decimal(9,2) (nullable = true)
|-- _col9: decimal(9,2) (nullable = true)
|-- _col10: date (nullable = true)
|-- _col11: decimal(9,2) (nullable = true)
|-- _col12: string (nullable = true)
|-- _col13: string (nullable = true)
但是当我尝试在创建的表上进行选择时出现以下错误:
select * from fact_scanv_dly_stg limit 5;
OK
Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.ClassCastException: org.apache.hadoop.hive.serde2.io.ByteWritable cannot
be cast to org.apache.hadoop.hive.serde2.io.HiveCharWritable
有什么建议吗??
【问题讨论】:
-
char(2)不应该是varchar(2)吗?此外,有些事情没有加起来。您创建的表没有任何十进制字段,但架构显示为十进制。这些是同一张桌子吗? -
位置的数据如何:'hdfs:///my/location/scanv_data/'?它有什么格式?能不能: hdfs dfs -ls hdfs:///my/location/scanv_data/ ,看看文件是什么格式的?
标签: apache-spark hive orc hive-serde