配置单元和主键约束

mspsb9vt  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(390)

以下hql在hdp2.6.1和hive 1.2.1000上生成错误。是直线问题还是Hive版本?

CREATE EXTERNAL TABLE IF NOT EXISTS `nwdb.strings` (`string_id` INT, `string_data` STRING, PRIMARY KEY(string_id) DISABLE NOVALIDATE) ROW FORMAT DELIMITED FIELDS TERMINATED BY "," LINES TERMINATED BY "\n" STORED AS TEXTFILE LOCATION "/data/nwdb/";

错误

Error: Error while compiling statement: FAILED: ParseException line 1:133 cannot recognize input near 'KEY' '(' 'string_id' in column type (state=42000,code=40000)

即使alter命令也会出现同样的错误

ALTER TABLE `aravind_stg_platform_nw_northwind_nwdb.strings` ADD CONSTRAINT string_id_PK PRIMARY KEY (`string_id`);
r7knjye2

r7knjye21#

对主键和外键的支持似乎来自hive2.1
https://issues.apache.org/jira/browse/hive-13290

相关问题