impala子查询返回奇怪的结果

4zcjmb1e  于 2021-06-24  发布在  Hive
关注(0)|答案(1)|浏览(376)

我运行下面的 Impala 查询,我得到奇怪的结果。为什么下面的第2个查询返回零结果,以及如何克服这个问题。我正在使用多个表执行多个数据管道,因此在开始时必须使用“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.
holgip5t

holgip5t1#

这似乎对我有利

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 你的第二个问题?

相关问题