Hive错误:parseexception缺少EOF

lex*_*lex 10 hadoop hive hiveql hcatalog

我不确定我在这里做错了什么:

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 ')'
Run Code Online (Sandbox Code Playgroud)

而以下查询完全正常:

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

我在这里错过了一些东西.任何指针都会有所帮助.谢谢!

Hai*_*ang 12

尝试将"LOCATION"放在"tblproperties"前面,如下所示,为我工作.

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

甚至连"Programming Hive"一书中的示例SQL都得到了错误的订单.请参考create table命令的官方定义:

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


Ani*_*non 5

@Haiying Wang指出,LOCATION是要放在前面的tblproperties

location但我认为当上面指定时也会发生该错误stored as

最好坚持正确的顺序:

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)
Run Code Online (Sandbox Code Playgroud)

参考:Hive 创建表