报错信息:Error: Error while compiling statement

建表语句:

create external table table_sample(v1 string,v2 string,v3 string) 
STORED AS PARQUET 
TBLPROPERTIES('parquet.compression'='gzip') 
location '/user/spark/cmd/table_sample';

报错信息:

Error: Error while compiling statement: FAILED: ParseException line 4:0 missing EOF at 'location' near ')' (state=42000,code=40000)

报错原因:建表时参数顺序问题,建议建表时参考官网示例建表。

此处把【TBLPROPERTIES】参数放到【location】之后即可,修改后的sql如下。

create external table table_sample(v1 string,v2 string,v3 string) 
STORED AS PARQUET 
location '/user/spark/cmd/table_sample' 
TBLPROPERTIES('parquet.compression'='gzip');​

新sql执行结果:

INFO : Compiling command(queryId=hive_20180411093333_1c920025-7e79-4d6f-a4f9-d42a2af0e2d8): create external table table_sample(v1 string,v2 string,v3 string)STORED AS PARQUET
location '/user/spark/cmd/table_sample'
TBLPROPERTIES('parquet.compression'='gzip')
INFO : Semantic Analysis Completed
INFO : Returning Hive schema: Schema(fieldSchemas:null, properties:null)
INFO : Completed compiling command(queryId=hive_20180411093333_1c920025-7e79-4d6f-a4f9-d42a2af0e2d8); Time taken: 0.171 seconds
INFO : Executing command(queryId=hive_20180411093333_1c920025-7e79-4d6f-a4f9-d42a2af0e2d8): create external table table_sample(v1 string,v2 string,v3 string)STORED AS PARQUET
location '/user/spark/cmd/table_sample'
TBLPROPERTIES('parquet.compression'='gzip')
INFO : Starting task [Stage-0:DDL] in serial mode
INFO : Completed executing command(queryId=hive_20180411093333_1c920025-7e79-4d6f-a4f9-d42a2af0e2d8); Time taken: 0.127 seconds
INFO : OK​

官网建表语句参考:

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)

 

 

 

你可能感兴趣的:(hive)