I'm trying to create a table in Hadoop but with the current_timestamp() as default value for a column:
CREATE TABLE table_test(
CODE_FIRST VARCHAR(3),
TYPE_TEST_1 VARCHAR(4),
TYPE_TEST_2 VARCHAR(4),
FLAG_BOOL VARCHAR(1),
CONTACT VARCHAR(15),
DATE_MODIFIED TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
) STORED AS parquet TBLPROPERTIES("parquet.compress"="GZIP");
I've tried to change it to AS CURRENT_TIMESTAMP
and many other formats but I'm not able to create the table. Could someone explain me what am I doing wrong?
Hive version 2.1.1-mapr-1901
The error:
Error while compiling statement:
FAILED: ParseException line 50:25 mismatched input 'DEFAULT' expecting ) near 'TIMESTAMP' in create table statement
CodePudding user response:
DEFAULT
constraint in Hive DDL was implemented in version 3.0, see JIRA HIVE-18726.
Ashutosh Chauhan added a comment - 22/May/18 23:16
This jira is resolved and released with Hive 3.0 If you find an issue with it, please create a new jira.
But even in that version, you can only define the constraints on MANAGED tables, and MANAGED tables do not support Parquet format.
For EXTERNAL tables (that can work with Parquet files), only RELY
constraint is supported, according to Hive manual.