Hive version- create Primary key

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);
at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(
at org.antlr.runtime.BaseRecognizer.match(
at org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(
at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(
at org.apache.hadoop.hive.ql.Driver.compile(
at org.apache.hadoop.hive.ql.Driver.compile(
at org.apache.hadoop.hive.ql.Driver.compileInternal(
at org.apache.hadoop.hive.ql.Driver.runInternal(
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(
at org.apache.hadoop.hive.cli.CliDriver.processCmd(
at org.apache.hadoop.hive.cli.CliDriver.processLine(
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(
at org.apache.hadoop.hive.cli.CliDriver.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.hadoop.util.RunJar.main(
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.


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