【问题标题】:cannot access columns in hive external table无法访问 hive 外部表中的列
【发布时间】:2019-09-05 14:38:44
【问题描述】:

使用命令后:

CREATE EXTERNAL TABLE IF NOT EXISTS items(
        item_id String,
        recommended_list String)
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY '\t'
    ESCAPED BY ''
    LINES TERMINATED By '\n'
    STORED AS TEXTFILE
    location '/user/kite/items';

创建了一个表。当我使用

select * from items limit 2; 

我明白了

100885        107525,562214
100023        655555,222222

正如预期的那样。然而,

 select item_id from items;
gives me an error
   Total jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
java.io.IOException: cannot find dir = maprfs:///user/kite/items in pathToPartitionInfo: [maprfs:/user/kite/items]
        at org.apache.hadoop.hive.ql.io.HiveFileFormatUtils.getPartitionDescFromPathRecursively(HiveFileFormatUtils.java:344)
        at org.apache.hadoop.hive.ql.io.HiveFileFormatUtils.getPartitionDescFromPathRecursively(HiveFileFormatUtils.java:306)
        at org.apache.hadoop.hive.ql.io.CombineHiveInputFormat$CombineHiveInputSplit.<init>(CombineHiveInputFormat.java:108)
        at org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.getSplits(CombineHiveInputFormat.java:455)
        at org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:1098)
        at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1090)
        at org.apache.hadoop.mapred.JobClient.access$500(JobClient.java:176)
        at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:931)
        at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:882)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1595)
        at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:882)
        at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:856)
        at org.apache.hadoop.hive.ql.exec.mr.ExecDriver.execute(ExecDriver.java:420)
        at org.apache.hadoop.hive.ql.exec.mr.MapRedTask.execute(MapRedTask.java:136)
        at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:153)
        at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:85)
        at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1503)
        at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1270)
        at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1088)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:911)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:901)
        at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:268)
        at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
        at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:423)
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:792)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
        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:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Job Submission failed with exception 'java.io.IOException(cannot find dir = maprfs:///user/kite/items in pathToPartitionInfo: [maprfs:/user/kite/items])'

【问题讨论】:

  • 您的代码指向一个位置,而您的错误消息指向另一个位置。需要解释一下吗?
  • 我对其进行了编辑以避免混淆。我不想公开分享确切的位置。
  • 因此您需要有关位置相关错误的帮助,但您不愿意分享位置。似乎适得其反。
  • 使用show create table/desc formatted验证实际位置
  • 我已经验证过了。我可以做 hadoop fs -text user/kite/items 并查看这些项目。甚至 select * 仅在我指定列名时才有效。

标签: hive hdfs


【解决方案1】:

你能指定/user/kite/items下的文件名和扩展名吗?

我遇到了完全相同的问题,我尝试了以下方法:
1.删​​除hive表
2. 将文件(以前没有扩展名)重命名为 csv 文件
3. 重新创建表。现在我可以像往常一样访问各个列并进行操作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多