【问题标题】:Impala sub-query returns strange resultImpala 子查询返回奇怪的结果
【发布时间】:2019-06-18 16:59:41
【问题描述】:

我正在运行下面的 impala 查询,但得到了奇怪的结果。为什么下面的第二个查询返回零结果以及如何克服这个问题。我正在用多个表做几个数据管道,所以我必须在开始时使用“with”。

1. Query: select * from test where name <> 'INSERT'
+----+--------+
| id | name   |
+----+--------+
| 2  | DELETE |
| 2  | HELLO  |
+----+--------+
Fetched 2 row(s) in 0.13s


2. Query: with temp as (select * from test where name <> 'INSERT') select * from temp
Modified 0 row(s) in 0.23s


3. Query: with temp as (select * from test where name <> 'HELLO') select * from temp
+----+--------+
| id | name   |
+----+--------+
| 2  | DELETE |
| 1  | INSERT |
+----+--------+
Fetched 2 row(s) in 0.12s


It should give the record names with 'HELLO' and 'DELETE' for the 2nd query. but its giving no results. Also noticed the output says "modified", so i am guessing its trying to execute it as DML.

Note : Using Impala Shell v2.11.0-cdh5.14.2

The same query works fine in hive.

【问题讨论】:

  • 如果您尝试在第二个查询中执行 explain ... 怎么办?是不是和3rd很像?
  • 计划-ROOT SINK | | | | | 01:EXCHANGE [未分区] | | | | | 00:扫描 HDFS [hello.temp] | |分区=1/1 文件=3 大小=26B | |谓词:name != 'HELLO'
  • 是的,除了最后一部分,它看起来完全一样。

标签: hive impala


【解决方案1】:

它似乎对我有用

with temp as (SELECT *
FROM
  (SELECT 'DELETE' AS name
   UNION SELECT 'HELLO' AS name
   UNION SELECT 'INSERT' AS name) AS subq
WHERE name <> 'INSERT')
select * from temp;
+---------+
|  name   |
+---------+
| HELLO   |
| DELETE  |
+---------+
2 rows selected (0.118 seconds)

您可以发布第二个查询的EXPLAIN PLAN 吗?

【讨论】:

  • 抱歉过了一段时间才回复。以下是解释的回复。 | 01:EXCHANGE [未分区] | | | | | 00:扫描 HDFS [hello.temp] | |分区=1/1 文件=3 大小=26B | |谓词:name != 'INSERT' |
  • 我执行了您的查询,但使用 Impala shell 仍然没有结果。令人惊讶的是,在 where 条件下也没有其他值的结果。相同的查询在 Hive CLI 中运行良好
  • 抱歉,稍等片刻才回复。看看这个dbfiddle。它在 Postgres 上,但与 Impala 的结果应该完全相同
猜你喜欢
  • 1970-01-01
  • 2020-04-06
  • 2014-12-31
  • 2017-02-26
  • 2018-09-01
  • 2012-05-30
  • 2019-12-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多