配置单元错误:parseexception缺少eof

wd2eg0qa  于 2021-06-04  发布在  Hadoop
关注(0)|答案(6)|浏览(1860)

我不确定我做错了什么:

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 ')'

虽然以下查询可以很好地工作:

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

我是不是漏掉了什么。任何提示都会有帮助。谢谢!

rjjhvcjd

rjjhvcjd1#

试着把“位置”放在“tblproperty”前面,像下面这样,对我有用。

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

似乎连“ProgrammingHive”一书中的示例sql都搞错了顺序。请参考create table命令的官方定义:
https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl#languagemanualddl-创建表

apeeds0o

apeeds0o2#

如果在使用命令“hive-f file.hql”从文件运行hiveql时看到此错误。它指向查询的第一行,这是因为忘记了分号(;)对于上一个查询。因为解析器查找分号(;)作为每个查询的终止符。例如:
drop table if exists default.emp create table default.emp(field1 type,field2 type)行格式分隔字段,以“|”结尾,存储为textfile location“s3://gts promocube/source data/lowes/pos/”;
如果您将上述内容保存在一个文件中并使用hive-f执行它,那么您将得到错误:failed:parseexception line 2:0 missing eof at'create'near emp。
解决方法:用分号(;)对于上面的drop table命令。

31moq8wy

31moq8wy3#

在配置单元中创建表时出现相同错误。
我使用drop命令删除表,然后再次运行createtable命令。
为我工作。

s6fujrry

s6fujrry4#

@王海英指出 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)

请参阅:配置单元创建表

yyyllmsg

yyyllmsg5#

查看此帖子:
将数据从.txt文件加载到配置单元中存储为orc的表中
并检查指定目录中的源文件 /user/hive/test_table . 万一文件在 .txt 或者其他的 non ORC 格式化然后你可以按照上面帖子中的步骤来走出错误。

omvjsjqw

omvjsjqw6#

“schemaname”附近的“.”处缺少parseexception行号eof:
在尝试从linux脚本执行以下命令以截断配置单元表时出现上述错误
dse-u username-p password hive-e“截断表keyspace.tablename;”
修复:需要在脚本行中分离命令,如下所示-
dse-u username-p password hive-e“使用密钥空间;截断表keyspace.tablename;”
快乐的编码!

相关问题