Skip to content

Commit 6378958

Browse files
adriangbclaude
andcommitted
test: add EXPLAIN assertion for __datafusion_extracted alias allocation
Adds an EXPLAIN query to verify the user-provided __datafusion_extracted_2 alias is preserved while optimizer-generated aliases skip to _3 and _4, guarding against silent regressions in alias allocation. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent c6774b6 commit 6378958

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎datafusion/sqllogictest/test_files/projection_pushdown.slt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,23 @@ CREATE EXTERNAL TABLE t
19661966
STORED AS PARQUET
19671967
LOCATION 'test_files/scratch/projection_pushdown/test.parquet';
19681968

1969+
# Verify that the user-provided __datafusion_extracted_2 alias is preserved
1970+
# and the optimizer skips to _3 and _4 for its generated aliases.
1971+
query TT
1972+
EXPLAIN SELECT
1973+
get_field(s, 'f1') AS __datafusion_extracted_2
1974+
FROM t
1975+
WHERE COALESCE(get_field(s, 'f1'), get_field(s, 'f2')) = 1;
1976+
----
1977+
logical_plan
1978+
01)Projection: __datafusion_extracted_2
1979+
02)--Filter: CASE WHEN __datafusion_extracted_3 IS NOT NULL THEN __datafusion_extracted_3 ELSE __datafusion_extracted_4 END = Int64(1)
1980+
03)----Projection: get_field(t.s, Utf8("f1")) AS __datafusion_extracted_3, get_field(t.s, Utf8("f2")) AS __datafusion_extracted_4, get_field(t.s, Utf8("f1")) AS __datafusion_extracted_2
1981+
04)------TableScan: t projection=[s], partial_filters=[CASE WHEN get_field(t.s, Utf8("f1")) IS NOT NULL THEN get_field(t.s, Utf8("f1")) ELSE get_field(t.s, Utf8("f2")) END = Int64(1)]
1982+
physical_plan
1983+
01)FilterExec: CASE WHEN __datafusion_extracted_3@0 IS NOT NULL THEN __datafusion_extracted_3@0 ELSE __datafusion_extracted_4@1 END = 1, projection=[__datafusion_extracted_2@2]
1984+
02)--DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/projection_pushdown/test.parquet]]}, projection=[get_field(s@0, f1) as __datafusion_extracted_3, get_field(s@0, f2) as __datafusion_extracted_4, get_field(s@0, f1) as __datafusion_extracted_2], file_type=parquet
1985+
19691986
query I
19701987
SELECT
19711988
get_field(s, 'f1') AS __datafusion_extracted_2

0 commit comments

Comments
 (0)