Hive error: parseexception missing EOF

匿名 (未验证) 提交于 2019-12-03 00:48:01

问题:

I am not sure what I am doing wrong here:

hive> CREATE TABLE default.testtbl(int1 INT,string1 STRING)         stored as orc        tblproperties ("orc.compress"="NONE")        LOCATION "/user/hive/test_table";        FAILED: ParseException line 1:107 missing EOF at 'LOCATION' near ')' 

while the following query works perfectly fine:

hive>  CREATE TABLE default.testtbl(int1 INT,string1 STRING)          stored as orc         tblproperties ("orc.compress"="NONE");        OK        Time taken: 0.106 seconds 

Am I missing something here. Any pointers will help. Thanks!

回答1:

Try put the "LOCATION" in front of "tblproperties" like below, worked for me.

CREATE TABLE default.testtbl(int1 INT,string1 STRING)     stored as orc    LOCATION "/user/hive/test_table"   tblproperties ("orc.compress"="NONE"); 

It seems even the sample SQL from book "Programming Hive" got the order wrong. Please reference to the official definition of create table command:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable



回答2:

@Haiying Wang pointed out that LOCATION is to be put in front of tblproperties.

But I think the error also occurs when location is specified above stored as.

Its better to stick to the correct order:

CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name    -- (Note: TEMPORARY available in Hive 0.14.0 and later)   [(col_name data_type [COMMENT col_comment], ... [constraint_specification])]   [COMMENT table_comment]   [PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)]   [CLUSTERED BY (col_name, col_name, ...) [SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS]   [SKEWED BY (col_name, col_name, ...)                  -- (Note: Available in Hive 0.10.0 and later)]      ON ((col_value, col_value, ...), (col_value, col_value, ...), ...)      [STORED AS DIRECTORIES]   [    [ROW FORMAT row_format]     [STORED AS file_format]      | STORED BY 'storage.handler.class.name' [WITH SERDEPROPERTIES (...)]  -- (Note: Available in Hive 0.6.0 and later)   ]   [LOCATION hdfs_path]   [TBLPROPERTIES (property_name=property_value, ...)]   -- (Note: Available in Hive 0.6.0 and later)   [AS select_statement];   -- (Note: Available in Hive 0.5.0 and later; not supported for external tables) 

Refer: Hive Create Table



回答3:

Check this post:

Loading Data from a .txt file to Table Stored as ORC in Hive

And check your source files present at the specified directory /user/hive/test_table. Incase the files are in .txt or some other non ORC format then you can follow the steps in the above post to come out of the error.



回答4:

ParseException line lineNumber missing EOF at '.' near 'schemaName':

Got the above error while trying to execute the following command from linux script to truncate a hive table

dse -u username -p password hive -e "truncate table keyspace.tablename;"

Fix: Need to separate the commands within the script line as follows -

dse -u username -p password hive -e "use keyspace; truncate table keyspace.tablename;"

Happy coding!



回答5:

Got the same error while creating a table in hive.

I used the drop command to drop the table and then run the create table command that I had again.

Worked for me.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!