具有非相等相关谓词的不支持的聚合子查询
Unsupported aggregate subquery with non-equality correlated predicates
我是 Impala 的新手 - 当我们连接两个表时收到以下错误消息,如下所示。
Impala 不支持 >= 相关子队列 - 任何建议我们如何做到这一点
CREATE TABLE database.test_dve (
campo1 INT,
campo2 TIMESTAMP,
campo3 INT
)
STORED AS PARQUET;
insert into database.test_dve values(1,'2019-09-30',1);
insert into database.test_dve values(2,'2019-09-30',1);
insert into database.test_dve values(3,'2019-09-30',1);
CREATE TABLE database.test_dve2 (
campo1 INT,
campo2 TIMESTAMP
)
STORED AS PARQUET;
insert into database.test_dve2 values(1,'2019-10-30');
select *
from database.test_dve a
WHERE 0 >= (SELECT count(*) FROM database.test_dve2 b
WHERE a.campo1 = b.campo1
AND CAST(from_timestamp(a.campo2, 'yyyyMM') as INT) >= CAST(from_timestamp(b.campo2, 'yyyyMM') as INT)
);
错误信息
[HY000] [Cloudera][ImpalaODBC] (110) 在 Impala 中执行查询时出错:[HY000]:AnalysisException:不支持的聚合子查询具有非等式相关谓词: CAST(from_timestamp(a.campo2, 'yyyyMM') AS INT) >= CAST(from_timestamp(b.campo2, 'yyyyMM') AS INT)
谢谢
尝试将其替换为 not exists
:
select *
from database.test_dve a
WHERE NOT EXISTS (SELECT 1
FROM database.test_dve2 b
WHERE a.campo1 = b.campo1 AND
CAST(from_timestamp(a.campo2, 'yyyyMM') as INT) >= CAST(from_timestamp(b.campo2, 'yyyyMM') as INT)
);
我是 Impala 的新手 - 当我们连接两个表时收到以下错误消息,如下所示。 Impala 不支持 >= 相关子队列 - 任何建议我们如何做到这一点
CREATE TABLE database.test_dve (
campo1 INT,
campo2 TIMESTAMP,
campo3 INT
)
STORED AS PARQUET;
insert into database.test_dve values(1,'2019-09-30',1);
insert into database.test_dve values(2,'2019-09-30',1);
insert into database.test_dve values(3,'2019-09-30',1);
CREATE TABLE database.test_dve2 (
campo1 INT,
campo2 TIMESTAMP
)
STORED AS PARQUET;
insert into database.test_dve2 values(1,'2019-10-30');
select *
from database.test_dve a
WHERE 0 >= (SELECT count(*) FROM database.test_dve2 b
WHERE a.campo1 = b.campo1
AND CAST(from_timestamp(a.campo2, 'yyyyMM') as INT) >= CAST(from_timestamp(b.campo2, 'yyyyMM') as INT)
);
错误信息
[HY000] [Cloudera][ImpalaODBC] (110) 在 Impala 中执行查询时出错:[HY000]:AnalysisException:不支持的聚合子查询具有非等式相关谓词: CAST(from_timestamp(a.campo2, 'yyyyMM') AS INT) >= CAST(from_timestamp(b.campo2, 'yyyyMM') AS INT)
谢谢
尝试将其替换为 not exists
:
select *
from database.test_dve a
WHERE NOT EXISTS (SELECT 1
FROM database.test_dve2 b
WHERE a.campo1 = b.campo1 AND
CAST(from_timestamp(a.campo2, 'yyyyMM') as INT) >= CAST(from_timestamp(b.campo2, 'yyyyMM') as INT)
);