New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Predicate push down bug #13565
Comments
Reproducible on current master also with the memory connector USE memory.default;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
DROP VIEW IF EXISTS v1;
CREATE TABLE t1 (c1 varchar);
CREATE TABLE t2 (c1 varchar);
CREATE TABLE t3 (a varchar, b varchar);
CREATE VIEW v1 AS
SELECT * FROM t1 UNION ALL SELECT * FROM t2;
INSERT INTO t1 VALUES '1';
SELECT a
FROM (
SELECT a, b FROM t3
UNION ALL
SELECT NULL AS a, NULL AS b FROM (
SELECT bb.c1
FROM (SELECT c1 FROM v1) aa
JOIN (SELECT c1 FROM v1) bb ON aa.c1 = bb.c1
)
)
WHERE CAST(a AS TIMESTAMP) >= timestamp '2022-08-01 00:00:00'
AND b IN ('hello'); -- query also fails with `= 'hello'` here
|
It's happening because during predicate pushdown, the following predicate is derived:
Then, it incorrectly establishes the equivalence |
Here's a simpler reproduction: WITH t AS (
SELECT CAST(null AS varchar) AS x, CAST(null AS varchar) AS y
FROM (VALUES 1) t(a) JOIN (VALUES 1) u(a) USING (a)
)
SELECT * FROM t
WHERE CAST(x AS BIGINT) IS NOT NULL AND y = 'hello'; |
I believe the failure is not guaranteed, hence |
@martint supposes it's not a correctness issue. I have no evidence it is, so removing the label. |
I found the issue in versions 364,380, 392
Query 20220809_115635_06050_yjfzd failed: Value cannot be cast to timestamp: hello
I find the unexpected filter in the plan:
(CAST(VARCHAR 'hello' AS timestamp) >= TIMESTAMP '2022-08-01 00:00:00.000'))
The text was updated successfully, but these errors were encountered: