在实现过程中,尝试更改配置单元中现有数据库的hdfs路径,
从特定路径更改/apps/hive/warehouse/hdfs路径我遇到以下异常,因为无法识别alter database语句中数据库集位置附近的输入我创建的数据库正在使用它创建表。
请帮助纠正的可能性和解决这个问题。此时此刻,我正在创建另一个数据库,具体位置如下
创建数据库db_migg location'/sit/dwh/hdata/db_migg';
hive> describe database db_mig;
OK
db_mig hdfs://nnscbhaastest/apps/hive/warehouse/db_mig.db hiveuser USER
Time taken: 0.145 seconds, Fetched: 1 row(s)
hive> use db_mig;
OK
Time taken: 0.258 seconds
hive> show tables;
OK
table_mig
Time taken: 0.163 seconds, Fetched: 1 row(s)
hive> ALTER DATABASE db_mig SET LOCATION '/sit/dwh/hdata/db_mig';
NoViableAltException(26@[])
at org.apache.hadoop.hive.ql.parse.HiveParser.alterDatabaseStatementSuffix(HiveParser.java:10592)
at org.apache.hadoop.hive.ql.parse.HiveParser.alterStatement(HiveParser.java:9028)
at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:4057)
at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1786)
at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1152)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:211)
at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:171)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:438)
at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:321)
at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1224)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1265)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1161)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1151)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:217)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:169)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:380)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:740)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:685)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
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:497)
at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
FAILED: ParseException line 1:15 cannot recognize input near 'db_mig' 'SET' 'LOCATION' in alter database statement ```
1条答案
按热度按时间new9mtju1#
看来你用的是旧版本的Hive。您需要配置单元版本2.2.1、2.4.0或更高版本。请查看Hive维基了解更多信息。
如果您使用的是较低版本的配置单元,请尝试使用alter位置删除并重新创建数据库,而不是在alter脚本中使用它,如下所示: