hadoop—在创建外部临时表时在配置单元中使用sql保留字

ecfsfe2w  于 2021-05-27  发布在  Hadoop
关注(0)|答案(1)|浏览(351)

我需要从hdfs位置创建一个外部配置单元表,其中文件中的一列具有保留名称(end)。
运行脚本时出现错误:“无法识别列规范中“end”“struct”“<”附近的输入”
我找到了两个解决方案。
第一个是设置hive.support.sql11.reserved.keywords=false,但是这个选项已经被删除了。https://issues.apache.org/jira/browse/hive-14872
第二种解决方案是使用带引号的标识符( column ).
但在本例中,我得到了错误:“org.apache.hadoop.hive.serde2.serdeexception:org.codehaus.jackson.jsonparseexception:unexpected character('c'(code 99)):需要逗号分隔对象条目”
这是我创建表的代码:

CREATE TEMPORARY EXTERNAL TABLE ${tmp_db}.${tmp_table}
(
    id STRING,
    email STRUCT<string:STRING>,
    start STRUCT<long:BIGINT>,
    end STRUCT<long:BIGINT>
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
LOCATION '${input_dir}';

无法重命名列。
有人知道这个问题的解决办法吗?或者有什么想法?提前多谢了!

5anewei6

5anewei61#

你能试试下面吗。

hive> set hive.support.quoted.identifiers=column;
hive> create temporary table sp_char ( `#` int, `end` string);

正常时间:0.123秒

OK
Time taken: 0.362 seconds
hive>

设置配置单元属性时 hive.support.quoted.identifiers=column 后记号中的所有值都被视为文字。上述属性的其他值为none,当设置为none时,可以使用regex计算列或表达式值。
希望这有帮助

相关问题