I have the following:
hive> CREATE TABLE foo (bar timestamp) STORED AS ORC;
OK
Time taken: 0.041 seconds
hive> INSERT INTO TABLE foo VALUES ('2014-01-17 00:17:13');
NoViableAltException(26#[])
at org.apache.hadoop.hive.ql.parse.HiveParser_SelectClauseParser.selectClause(HiveParser_SelectClauseParser.java:742)
at org.apache.hadoop.hive.ql.parse.HiveParser.selectClause(HiveParser.java:40184)
at org.apache.hadoop.hive.ql.parse.HiveParser.singleSelectStatement(HiveParser.java:38048)
at org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:37754)
at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:37654)
at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:36898)
at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:36774)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1338)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1036)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:408)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:322)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:976)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1041)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:912)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:902)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:268)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:423)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:793)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
FAILED: ParseException line 1:22 cannot recognize input near 'values' '(' ''2014-01-17 00:17:13'' in select clause
What is the correct way of inserting timestamps into a Hive table?
Hive version is: hive-0.13.0
According to Hive Language Manual "INSERT...VALUES is available starting in Hive 0.14".
So, you have only two options left:
Insert timestamp value from existing table or call a function to get it (e.g. from_unixtime(unix_timestamp()), see this answer for example)
Load data from a file.
This kind of writing is correct:
insert into table foo;
select '2014-01-17 00:17:13' as bar from foo
Related
I am trying to create a table (CTAS) and I want it to have a multi-char delimiter to it like let’s say “#$“ or “^|^“.
Query:
CREATE TABLE IF NOT EXISTS <table_name>
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe'
WITH SERDEPROPERTIES ("field.delim"="##")
STORED AS TEXTFILE
AS
SELECT <columns> from <table> ;
While running it, is throwing NullPointerException:
ERROR : Job failed with java.lang.NullPointerException
java.util.concurrent.ExecutionException: Exception thrown by job
at org.apache.spark.JavaFutureActionWrapper.getImpl(FutureAction.scala:337)
at org.apache.spark.JavaFutureActionWrapper.get(FutureAction.scala:342)
at org.apache.hive.spark.client.RemoteDriver$JobWrapper.call(RemoteDriver.java:362)
at org.apache.hive.spark.client.RemoteDriver$JobWrapper.call(RemoteDriver.java:323)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 4, agent3659-phx3.prod.uber.internal, executor 1): java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Error while processing row (tag=0) {"key":{},"value":{"_col0":"<column_value>"}}
I have also tried RegexSerDe, same error.
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
WITH SERDEPROPERTIES ("input.regex" = "^(\\d+)~\\*(.*)$")
Will be great to get your inputs on this.
I'm a little lost. Why are you even using a file format specification if the data is already in a table? Just use:
CREATE TABLE IF NOT EXISTS <table_name>
SELECT <columns>
FROM <table> ;
I have a hive external table partitioned on dt(string).
Some values in partitioned column are none, which means that these rows go into the null partition(dt=HIVE_DEFAULT_PARTITION). I want to update location for this partition.
0: jdbc:hive2://localhost:10000/> alter table `zdb.table` partition(dt=__HIVE_DEFAULT_PARTITION__) set location "s3a://path/zdb.db/table/dt=__HIVE_DEFAULT_PARTITION__";
Error: Error while compiling statement: FAILED: ParseException line 1:71 missing \' at ')' near '<EOF>' (state=42000,code=40000)
0: jdbc:hive2://localhost:10000/> alter table `zdb.table` partition(dt=null) set location "s3a://path/zdb.db/table/dt=__HIVE_DEFAULT_PARTITION__";
Error: Error while compiling statement: FAILED: SemanticException [Error 10248]: Cannot add partition column dt of type void as it cannot be converted to type string (state=42000,code=10248)
0: jdbc:hive2://localhost:10000/> alter table `zdb.table` partition(dt="__HIVE_DEFAULT_PARTITION__") set location "s3a://path/zdb.db/table/dt=__HIVE_DEFAULT_PARTITION__";
Error: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Unable to alter partition. Unable to alter partitions because table or database does not exist.
at org.apache.hive.service.cli.operation.Operation.toSQLException(Operation.java:380)
at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:257)
at org.apache.hive.service.cli.operation.SQLOperation.access$800(SQLOperation.java:91)
at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1844)
at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:363)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to alter partition. Unable to alter partitions because table or database does not exist.
at org.apache.hadoop.hive.ql.metadata.Hive.alterPartitions(Hive.java:743)
at org.apache.hadoop.hive.ql.exec.DDLTask.alterTable(DDLTask.java:3592)
at org.apache.hadoop.hive.ql.exec.DDLTask.execute(DDLTask.java:390)
at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:199)
at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:100)
at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:2183)
at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1839)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1526)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1237)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1232)
at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:255)
... 11 more
Caused by: InvalidOperationException(message:Unable to alter partitions because table or database does not exist.)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$alter_partitions_with_environment_context_result$alter_partitions_with_environment_context_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$alter_partitions_with_environment_context_result$alter_partitions_with_environment_context_resultStandardScheme.read(ThriftHiveMetastore.java)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$alter_partitions_with_environment_context_result.read(ThriftHiveMetastore.java)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:86)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_alter_partitions_with_environment_context(ThriftHiveMetastore.java:2843)
at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.alter_partitions_with_environment_context(ThriftHiveMetastore.java:2827)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.alter_partitions(HiveMetaStoreClient.java:1533)
at sun.reflect.GeneratedMethodAccessor166.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:173)
at com.sun.proxy.$Proxy34.alter_partitions(Unknown Source)
at sun.reflect.GeneratedMethodAccessor166.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient$SynchronizedHandler.invoke(HiveMetaStoreClient.java:2336)
at com.sun.proxy.$Proxy34.alter_partitions(Unknown Source)
at org.apache.hadoop.hive.ql.metadata.Hive.alterPartitions(Hive.java:739)
... 21 more (state=08S01,code=1)
Also, I noticed that drop partition is working
0: jdbc:hive2://localhost:10000/> alter table `zdb.table` drop partition(dt="__HIVE_DEFAULT_PARTITION__") ;
No rows affected (0.08 seconds)
Using the same syntax with add partition fails
0: jdbc:hive2://localhost:10000/> alter table `zdb.table` add partition(dt="__HIVE_DEFAULT_PARTITION__") location "s3a://path/zdb.db/table/dt=__HIVE_DEFAULT_PARTITION__";
Error: Error while compiling statement: FAILED: SemanticException [Error 10111]: Partition value contains a reserved substring (User value: __HIVE_DEFAULT_PARTITION__ Reserved substring: __HIVE_DEFAULT_PARTITION__) (state=42000,code=10111)
For my use-case, I cannot use msck repair table <table-name>. Please suggest if there is a work-around for this
enclose __HIVE_DEFAULT_PARTITION__ in quotes("") then you are able to set the location for default partition.
alter table `zdb.table` partition(dt="__HIVE_DEFAULT_PARTITION__") set location "s3a://path/zdb.db/table/dt=__HIVE_DEFAULT_PARTITION__";
We can't add __HIVE_DEFAULT_PARTITION__(as this is an reserved key word in hive) to the hive table but we can solve this issue using workaround.
INSERT INTO zdb.table PARTITION(DT) SELECT * FROM (SELECT <all columns except dt>,CAST(NULL AS STRING) DT )T;
Now __HIVE_DEFAULT_PARTITION__ will be available then we can use alter set location to change the partition location.
For example, when using Parquet format, I'd like to be able to specify the compression scheme (("parquet.compression"="SNAPPY")). Running this query:
CREATE TABLE table_a_copy
STORED AS PARQUET
TBLPROPERTIES("parquet.compression"="SNAPPY")
AS
SELECT * FROM table_a
returns an error:
Error: Error while compiling statement: FAILED: ParseException line 1:69 cannot recognize input near 'parquet' '.' 'compression' in table properties list (state=42000,code=40000)
The same query without the TBLPROPERTIES works just fine.
This is similar to this question: Create hive table using "as select" or "like" and also specify delimiter. But I can't figure out how to make TBLPROPERTIES work with that approach. I'm using Hive 1.1.
I was able to run same exact statement in Hive 2.1.1 version.
Try with this workaround:
CREATE TABLE table_a_copy like table_a STORED AS PARQUET;
alter table set TBLPROPERTIES("parquet.compression"="SNAPPY");
insert into table table_a_copy select * from table_a ;
I am not able to remove a column using ALTER from an existing hive external table
Hive version is hive 1.1 inside CDH 5.5
hive> create external table alter_test(id int,name string)
> row format delimited
> fields terminated by ','
> location '/user/cloudera/conf_files';
OK
Time taken: 0.132 seconds
hive> select * from alter_test;
OK
100 surender
101 raja
Time taken: 0.141 seconds, Fetched: 2 row(s)
hive> alter table alter_test ADD COLUMNS (deviceid string,mode string,channels int,action_name string,data_countt int);
OK
Time taken: 0.2 seconds
hive> show create table alter_test;
OK
CREATE EXTERNAL TABLE `alter_test`(
`id` int,
`name` string,
`deviceid` string,
`mode` string,
`channels` int,
`action_name` string,
`data_countt` int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://nameservice1/user/cloudera/conf_files'
TBLPROPERTIES (
'COLUMN_STATS_ACCURATE'='false',
'last_modified_by'='build',
'last_modified_time'='1500048081',
'numFiles'='0',
'numRows'='-1',
'rawDataSize'='-1',
'totalSize'='0',
'transient_lastDdlTime'='1500048081')
Time taken: 0.049 seconds, Fetched: 25 row(s)
hive> select * from alter_test;
OK
100 surender NULL NULL NULL NULL NULL
101 raja NULL NULL NULL NULL NULL
Time taken: 0.123 seconds, Fetched: 2 row(s)
hive> alter table alter_test drop deviceid;
MismatchedTokenException(26!=187)
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_IdentifiersParser.dropPartitionSpec(HiveParser_IdentifiersParser.java:10571)
at org.apache.hadoop.hive.ql.parse.HiveParser.dropPartitionSpec (HiveParser.java:44608)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterStatementSuffixDropPartitions(HiveParser.java:11198)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterTableStatementSuffix(HiveParser.java:7748)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterStatement(HiveParser.java:6960)
at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2409)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1586)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1062)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:393)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:305)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1110)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1158)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1047)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1037)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:207)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:159)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:370)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:756)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
FAILED: ParseException line 1:28 mismatched input 'deviceid' expecting PARTITION near 'drop' in drop partition statement
hive> alter table alter_test drop column deviceid;
MismatchedTokenException(57!=187)
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_IdentifiersParser.dropPartitionSpec(HiveParser_IdentifiersParser.java:10571)
at org.apache.hadoop.hive.ql.parse.HiveParser.dropPartitionSpec(HiveParser.java:44608)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterStatementSuffixDropPartitions(HiveParser.java:11198)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterTableStatementSuffix(HiveParser.java:7748)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterStatement(HiveParser.java:6960)
at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2409)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1586)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1062)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:393)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:305)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1110)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1158)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1047)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1037)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:207)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:159)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:370)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:756)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
FAILED: ParseException line 1:28 mismatched input 'column' expecting PARTITION near 'drop' in drop partition statement
Is there any workaround to come out of this issue?
There is currently no command in Hive for dropping a column.
A column could be dropped implicitly by defining a new set of columns -
alter table alter_test
replace columns
(id int,name string,mode string,channels int,action_name string,data_countt int)
;
However, in your case it raises an exception -
Unable to alter table.
The following columns have types incompatible
with the existing columns in their respective positions :
channels,data_countt,
Query: alter table alter_test replace columns
(id int,name string,mode string,channels int,action_name
string,data_countt int).
We can work around it by doing it in 2 phases -
1.
alter table alter_test
replace columns
(id int,name string)
;
2.
alter table alter_test
add columns
(mode string,channels int,action_name string,data_countt int)
;
P.s.
Just to make it clear -
All the change are done in the metadata level only.
The data is not being changed.
P.s. 2
And off course you can drop the external table and recreate it...
it's better to create a new table a,then insert into table a from old table,after this drop the old table ,finally rename a to the old table name.
I created the following table in hive.
CREATE TABLE IF NOT EXISTS employee (
eid int,
name String,
salary String,
destination String
)
COMMENT ‘Employee details’
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\t’
LINES TERMINATED BY ‘\n’
STORED AS TEXTFILE;
The table is created successfully. I am trying to do the following insert
insert into TABLE employee (eid,name,salary,destination) VALUES (1,'avi','100000','boston');
However, I am getting the following error messages.
NoViableAltException(283#[])
at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:39678)
at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:38904)
at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:38780)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1514)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1052)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:389)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:303)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1067)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1129)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1004)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:994)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:201)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:153)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:364)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:712)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:631)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:570)
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:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
FAILED: ParseException line 1:27 cannot recognize input near '(' 'eid' ',' in statement
How can I fix this?
INSERT INTO employee select 1, 'avi', '100000', 'boston';
It seems your version does not support insert columns list nor values.
P.s.
The error message is very clear.
You should focus on the last line.
Remember you need quotation marks as you are trying to insert Strings. Also, the field names are not necessary as you are inserting a value for all fields in your table. You might simply try the following:
INSERT INTO TABLE employee
VALUES (1, 'avi', '100000', 'boston');
You can't insert the data like this or insert command because insert command use in SQL.
For loading data into hive you have to create a one text file and you have to upload that file using load command.
For example
LOAD DATA LOCAL INPATH 'YOUR TXT FILE LOCATION' OVERWRITE INTO TABLE TABLENAME;