Hive version- create Primary key

Hi
with current hive version available I am unable to create a primary key on a table can someone help me

Hi @sneha,

Could you please share the screenshot of the error so that we can assist you better.

create table test(col1 string,col2 int not null);
MismatchedTokenException(178!=312)
at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:617)
at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
at org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(HiveParser.java:6277)
at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:3682)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1771)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1139)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:202)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:438)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:321)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1221)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1262)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1158)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1148)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:217)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:169)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:380)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:740)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:685)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
FAILED: ParseException line 1:39 mismatched input ‘not’ expecting ) near ‘int’ in create table statement

Older version of the hive doesn’t support primary key but this support has been added in 2.1.0 version of hive. So please upgrade the hive version to 2.1 or above if any.

Hi @Janagaraj_Appusamy,

We will need to upgrade the entire cluster for the same. We will add this in our pipeline.

Thanks,
Abhinav

Hi Abhinav,

When can we expect latest version of hive?
The current version available is 1.2 that is deprecated.
As you said that you need to upgrade the entire cluster so i guess the versions of all other techs will also be deprecated versions in cloudxlab.

Thanks and Regards,
Amit Kumar Tyagi