Skip to content

Commit

Permalink
test(9678): reproducer for optimizer error (in common_subexpr_elimina…
Browse files Browse the repository at this point in the history
…te), as seen in other test case
  • Loading branch information
wiedld committed Mar 19, 2024
1 parent ff46614 commit f190b24
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions datafusion/sqllogictest/test_files/common_subexpr_eliminate.slt
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,56 @@ query RRR rowsort
select f64, case when f64 > 0 then 1.0 / f64 else null end, acos(case when f64 > 0 then 1.0 / f64 else null end) from doubles;
----
10.1 0.09900990099 1.471623942989


statement ok
CREATE EXTERNAL TABLE aggregate_test_100 (
c1 VARCHAR NOT NULL,
c2 TINYINT NOT NULL,
c3 SMALLINT NOT NULL,
c4 SMALLINT,
c5 INT,
c6 BIGINT NOT NULL,
c7 SMALLINT NOT NULL,
c8 INT NOT NULL,
c9 BIGINT UNSIGNED NOT NULL,
c10 VARCHAR NOT NULL,
c11 FLOAT NOT NULL,
c12 DOUBLE NOT NULL,
c13 VARCHAR NOT NULL
)
STORED AS CSV
WITH HEADER ROW
LOCATION '../../testing/data/csv/aggregate_test_100.csv'

# starting complex expression
query TIB
SELECT DISTINCT ON (chr(ascii(c1) + 3), c2 % 2) chr(ascii(upper(c1)) + 3), c2 % 2, c3 > 80
FROM aggregate_test_100
WHERE c1 IN ('a', 'b')
ORDER BY chr(ascii(c1) + 3), c2 % 2, c3 DESC;
----
D 0 false
D 1 true
E 0 false
E 1 false

# BUG: fix this
# added to boolean expr in the projections `AND c2 % 2 = 1`
# `Error during planning: No function matches the given name and argument types 'chr(Utf8)'`
#
query error DataFusion error: Optimizer rule 'common_sub_expression_eliminate' failed
SELECT DISTINCT ON (chr(ascii(c1) + 3), c2 % 2) chr(ascii(upper(c1)) + 3), c2 % 2, c3 > 80 AND c2 % 2 = 1
FROM aggregate_test_100
WHERE c1 IN ('a', 'b')
ORDER BY chr(ascii(c1) + 3), c2 % 2, c3 DESC;

# The projection `c2 % 2 = 1` is fine.
query B
SELECT c2 % 2 = 1
FROM aggregate_test_100
WHERE c1 IN ('a', 'b')
ORDER BY chr(ascii(c1) + 3), c2 % 2, c3 DESC
LIMIT 1;
----
false

0 comments on commit f190b24

Please sign in to comment.