Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ arrow = "57.0.0"
arrow-schema = "57.0.0"
async-trait = "0.1.89"
dashmap = "6"
datafusion = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-common = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-expr = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-functions = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-functions-aggregate = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-optimizer = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-physical-expr = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-physical-plan = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion-sql = { git = "https://github.com/massive-com/arrow-datafusion", rev = "9cd0824" }
datafusion = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-common = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-expr = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-functions = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-functions-aggregate = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-optimizer = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-physical-expr = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-physical-plan = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
datafusion-sql = { git = "https://github.com/massive-com/arrow-datafusion", rev = "cd6aaa6" }
futures = "0.3"
itertools = "0.14"
log = "0.4"
Expand Down
38 changes: 25 additions & 13 deletions src/materialized/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,20 +1830,32 @@ mod test {
SELECT year, column1 AS column2 FROM t3
",
projection: &["year"],
// In DF 52.4, the plan for coalesce changed due to apache/datafusion#20879
// ("Ensure columns are casted to the correct names with Unions").
// Previously, `coerce_exprs_for_schema` would alias any cast expression
// with the original column name, which kept `coalesce(CAST(...), t2.year)`
// as a single opaque expression. After the fix, only bare `Expr::Column`
// references get an alias on cast, so the inner `CAST(t1.year AS Utf8View)`
// is now visible to the optimizer. This triggers:
// 1. CSE (common subexpression elimination) extracts the shared
// `CAST(t1.year AS Utf8View)` (used in both coalesce and join condition)
// into `__common_expr_2`.
// 2. `coalesce(a, b)` is expanded to `CASE WHEN a IS NOT NULL THEN a ELSE b END`.
expected_plan: vec![
"+--------------+--------------------------------------------------------------------+",
"| plan_type | plan |",
"+--------------+--------------------------------------------------------------------+",
"| logical_plan | Union |",
"| | Projection: coalesce(CAST(t1.year AS Utf8View), t2.year) AS year |",
"| | Full Join: Using CAST(t1.year AS Utf8View) = t2.year |",
"| | SubqueryAlias: t1 |",
"| | Projection: t1.column1 AS year |",
"| | TableScan: t1 projection=[column1] |",
"| | SubqueryAlias: t2 |",
"| | TableScan: t2 projection=[year] |",
"| | TableScan: t3 projection=[year] |",
"+--------------+--------------------------------------------------------------------+",
"+--------------+---------------------------------------------------------------------------------------------------+",
"| plan_type | plan |",
"+--------------+---------------------------------------------------------------------------------------------------+",
"| logical_plan | Union |",
"| | Projection: CASE WHEN __common_expr_2 IS NOT NULL THEN __common_expr_2 ELSE t2.year END AS year |",
"| | Projection: CAST(t1.year AS Utf8View) AS __common_expr_2, t2.year |",
"| | Full Join: Using CAST(t1.year AS Utf8View) = t2.year |",
Comment on lines +1849 to +1851
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated expected plan asserts the internal CSE-generated alias __common_expr_2. That alias index is not a stable part of the API and can change with minor optimizer rule reordering, leading to brittle/failing tests without any functional regression. Consider normalizing the explain output before comparison (e.g., replace __common_expr_\d+ with a placeholder), or weakening this assertion to check for key operators/expressions without depending on the exact common-expr name/number.

Copilot uses AI. Check for mistakes.
"| | SubqueryAlias: t1 |",
"| | Projection: t1.column1 AS year |",
"| | TableScan: t1 projection=[column1] |",
"| | SubqueryAlias: t2 |",
"| | TableScan: t2 projection=[year] |",
"| | TableScan: t3 projection=[year] |",
"+--------------+---------------------------------------------------------------------------------------------------+",
],
expected_output: vec![
"+------+",
Expand Down
Loading