失败:parseexception行1:24无法识别表名中“using”“org”附近的输入(using org.apache.spark.sql.json)

oyxsuwqo  于 2021-05-24  发布在  Spark
关注(0)|答案(1)|浏览(610)

我想使用以下查询,但我得到一个错误。我在这里读到https://databricks.com/blog/2015/02/02/an-introduction-to-json-support-in-spark-sql.html 查询应该是正确的。

CREATE TABLE spark_logs USING org.apache.spark.sql.json OPTIONS (path "/data/web_logs/clicks.json");

NoViableAltException(275@[184:1: tableName : (db= identifier DOT tab=
identifier -> ^( TOK_TABNAME $db $tab) |tab= identifier -> ^(
TOK_TABNAME $tab) );])
        at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
        at org.antlr.runtime.DFA.predict(DFA.java:116)
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.tableName(HiveParser_FromClauseParser.java:4692)
        at org.apache.hadoop.hive.ql.parse.HiveParser.tableName(HiveParser.java:44923)
        at org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(HiveParser.java:4873)
        at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2557)
        at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1589)
        at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1065)
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:201)
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:522)
        at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1356)
        at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1473)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1285)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1275)
        at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:226)
        at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:175)
        at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:389)
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:781)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:699)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:634)
        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:24 cannot recognize input near
'spark_logs' 'USING' 'org' in table name

你知道为什么Hive无法识别吗 USING org.apache.spark.sql.json ?

xxslljrj

xxslljrj1#

您需要查阅最新的文档(databricks),而不是~5年前编写的文档:-)语法如下:

CREATE TABLE table_name 
USING JSON 
LOCATION 'path....';

更新:在1.6.x中,唯一受支持的语法是blog post中描述的(临时表,但不是hive表):

CREATE TEMPORARY TABLE people
    USING org.apache.spark.sql.json
    OPTIONS (path '[the path to the JSON dataset]')

相关问题