Hive:在简单的创建外部表查询

时间:2017-09-02 06:24:26

标签: hadoop hive hadoop2

我在mac上设置了配置单元。在执行简单的创建外部表查询时。我正在低于堆栈跟踪:

        hive> CREATE EXTERNAL TABLE weatherext ( wban INT, date STRING)
        > ROW FORMAT DELIMITED
        > FIELDS TERMINATED BY ‘,’
        > LOCATION ‘ /hive/data/weatherext’;
  

NoViableAltException(80 @ [])at org.apache.hadoop.hive.ql.parse.HiveParser.columnNameTypeOrPKOrFK(HiveParser.java:33341)           at org.apache.hadoop.hive.ql.parse.HiveParser.columnNameTypeOrPKOrFKList(HiveParser.java:29513)           在org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(HiveParser.java:6175)           在org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:3808)           在org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:2382)           在org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1333)           在org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:204)           在org.apache.hadoop.hive.ql.parse.ParseUtils.parse(ParseUtils.java:77)           在org.apache.hadoop.hive.ql.parse.ParseUtils.parse(ParseUtils.java:70)           在org.apache.hadoop.hive.ql.Driver.compile(Driver.java:468)           在org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1316)           在org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1456)           在org.apache.hadoop.hive.ql.Driver.run(Driver.java:1236)           在org.apache.hadoop.hive.ql.Driver.run(Driver.java:1226)           在org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:233)           在org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:184)           在org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:403)           在org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:821)           在org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:759)           在org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:686)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)           at java.lang.reflect.Method.invoke(Method.java:498)           在org.apache.hadoop.util.RunJar.run(RunJar.java:221)           在org.apache.hadoop.util.RunJar.main(RunJar.java:136)       FAILED:ParseException行1:45无法识别日期附近的输入' ' STRING' ')'在列名或主键或外键中。

我能够在ubuntu上成功运行相同的查询。 是否必须用`in hive2?

包围coulmn名字

1 个答案:

答案 0 :(得分:2)

  1. date是保留字,应该是合格的。
  2. 您使用的是错误的限定符。您应该使用'而不是
  3. 您所在位置的开头有空格/hive/data...
  4. CREATE EXTERNAL TABLE weatherext (wban INT, `date` STRING)
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    LOCATION '/hive/data/weatherext';