0

我需要从 hdfs 位置创建一个外部配置单元表,其中文件中的一列具有保留名称(结束)。

运行脚本时出现错误:“无法识别列规范中'end''STRUCT''<'附近的输入”

我找到了 2 个解决方案。

第一个是设置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)): was expecting comma to separate OBJECT entries”

这是我创建表的代码:

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}';

无法重命名该列。

有人知道这个问题的解决方案吗?或者可能有什么想法?提前非常感谢!

4

1 回答 1

0

你可以试试下面。

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

OK 耗时:0.123 秒

OK
Time taken: 0.362 seconds
hive>

当您设置 hive 属性时hive.support.quoted.identifiers=column,反引号内的所有值都被视为文字。上述属性的其他值是none,当它设置为 none 时,您可以使用正则表达式来评估列或表达式值。

希望这可以帮助

于 2019-02-16T13:53:54.527 回答