gpt4 book ai didi

hadoop - 创建具有Serde格式和额外列的外部表-HIVE

转载 作者:行者123 更新时间:2023-12-02 20:23:39 25 4
gpt4 key购买 nike

我正在尝试将txt文件导入到带有 hive 中额外列的外部表中,如下所示:


CREATE EXTERNAL TABLE IF NOT EXISTS bs.tbl_bt(
tp_registro string,
seq string,
num_a string,
dt_chamada string,
hr_chamada string,
num_b string,
pt_interconect string,
dur_rel_chamada string,
dur_tar_chamada string,
tp_servico string,
vl_liq_chamada string,
vl_brt_chamada string,
reserva string,
'${hiveconf:tez.task.operadora}' as operadora string)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
WITH SERDEPROPERTIES (input.regex = (.{1})(.{10})(.{21})(.{8})(.{6})(.{20})(.{10})(.{7})(.{7})(.{2})(.{11})(.{11})(.{29}).*)
STORED AS TEXTFILE
LOCATION '/gr/Fi/B/${hiveconf:tez.task.operadora}';
我究竟做错了什么?

最佳答案

定义列时,Hive DDL不包含AS

CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name    -- (Note: TEMPORARY available in Hive 0.14.0 and later)
[(col_name data_type [column_constraint_specification] [COMMENT col_comment], ... [constraint_specification])]

因此,尝试
'${hiveconf:tez.task.operadora}' STRING 

或者,如果您确实需要使该列始终保持可操作状态,则删除hiveconf变量

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable

也许您正在混淆CTAS语句,在创建表时可以在其中选择一列作为其他名称

关于hadoop - 创建具有Serde格式和额外列的外部表-HIVE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58721132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com