无法访问hive外部表中的列

时间:2017-06-01 19:51:21

标签: hive hdfs

使用命令后:

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

1 个答案:

答案 0 :(得分:0)

可以在/ user / kite / items下指定文件名和扩展名吗?

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