使用 WHERE 子句的查询不起作用

Posted

技术标签:

【中文标题】使用 WHERE 子句的查询不起作用【英文标题】:Query with WHERE clause not working 【发布时间】:2014-03-28 11:05:10 【问题描述】:

这是问题的延续 Integrating Hbase with Hive: Register Hbase table.

我正在从 Hive 查询一个外部 Hbase 表。

当我做一个简单的查询时

select * from Document_Table_Hive

查询有效,我得到了存储在表中的记录。

但是当我使用 where 子句进行查询时。它不起作用。

hive> select * from Document_Table_Hive where key = "news-9630";
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_1395999255539_0006, Tracking URL = http://sandbox.hortonworks.com:8088/proxy/application_1395999255539_0006/
Kill Command = /usr/lib/hadoop/bin/hadoop job  -kill job_1395999255539_0006
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
2014-03-28 04:00:19,441 Stage-1 map = 0%,  reduce = 0%
2014-03-28 04:01:01,873 Stage-1 map = 100%,  reduce = 0%
Ended Job = job_1395999255539_0006 with errors
Error during job, obtaining debugging information...
Examining task ID: task_1395999255539_0006_m_000000 (and more) from job job_1395999255539_0006

Task with the most failures(4):
-----
Task ID:
  task_1395999255539_0006_m_000000

URL:
  http://sandbox.hortonworks.com:8088/taskdetails.jsp?jobid=job_1395999255539_0006&tipid=task_1395999255539_0006_m_000000
-----
Diagnostic Messages for this Task:
Error: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.mapreduce.TableSplit
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
        at java.lang.Class.getConstructor0(Class.java:2699)
        at java.lang.Class.getDeclaredConstructor(Class.java:1985)
        at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
        at org.apache.hadoop.hive.ql.io.HiveInputFormat$HiveInputSplit.readFields(HiveInputFormat.java:144)
        at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:71)
        at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:42)
        at org.apache.hadoop.mapred.MapTask.getSplitDetails(MapTask.java:370)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:402)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:162)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:396)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:157)


FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
MapReduce Jobs Launched:
Job 0: Map: 1   HDFS Read: 0 HDFS Write: 0 FAIL
Total MapReduce CPU Time Spent: 0 msec

我知道这是一个类路径问题,但我已将所有 .jars 复制到 /usr/lib/Hive/lib/。我该如何解决这个问题?

【问题讨论】:

【参考方案1】:
hive> select * from test1 where name = 'Amutha';  
Total MapReduce jobs = 1  
Launching Job 1 out of 1  
Number of reduce tasks is set to 0 since there's no reduce operator  
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0  
2014-09-24 18:16:07,230 Stage-1 map = 0%,  reduce = 0%  
2014-09-24 18:16:18,337 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:19,344 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:20,364 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:21,385 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:22,409 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:23,417 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:24,425 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:25,433 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:26,548 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:27,560 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:28,568 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:29,576 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 2.21 sec  
2014-09-24 18:16:30,598 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 2.21 sec  
MapReduce Total cumulative CPU time: 2 seconds 210 msec  
Ended Job = job_201409241729_0005  
MapReduce Jobs Launched:  
Job 0: Map: 1   Cumulative CPU: 2.21 sec   HDFS Read: 323 HDFS Write: 0 SUCCESS  
Total MapReduce CPU Time Spent: 2 seconds 210 msec  
OK  
Time taken: 40.095 seconds  
hive> 

【讨论】:

你能更好地格式化这些信息吗?这个答案不够清楚 如果您实际上稍微解释一下您的答案,而不是仅仅转储您的输出,这也会有所帮助。 能提供安装的Hbase、Hadoop、Hive的版本吗?

以上是关于使用 WHERE 子句的查询不起作用的主要内容,如果未能解决你的问题,请参考以下文章

带有 WHERE 子句和 INNER JOIN 的 MySQL 更新查询不起作用

Sql where子句不起作用

用于有序字符串的 postgresql where 子句不起作用

BigQuery 的 WHERE 子句中的 SELECT 语句不起作用

LINQ where 子句中的 async/await 不起作用

为啥我的 WHERE 子句在我的组合框中不起作用