Skip to content

[GLUTEN-11550][VL] Enable GlutenDataFrameSubquerySuite for Spark 4.1 - #11727

Merged
zhouyuan merged 1 commit into
apache:mainfrom
baibaichen:fix/GlutenDataFrameSubquerySuite
Mar 11, 2026
Merged

zhouyuan merged 1 commit into
apache:mainfrom
baibaichen:fix/GlutenDataFrameSubquerySuite

Conversation

@baibaichen

@baibaichen baibaichen commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

Fix struct join key validation and enable GlutenDataFrameSubquerySuite for Spark 4.1.

Spark 4.1 added isin(Dataset) API which creates struct IN subquery predicates. These are converted to BroadcastHashJoin with struct-typed join keys where field names may differ between sides (e.g., struct(a, b) vs struct(c, d)).

Changes:

  1. JoinExecTransformer.scala — Remove struct field name comparison in sameType() to align with Spark's DataType.equalsStructurally(ignoreNullability=true) semantics. Spark's native HashJoin only checks structural type compatibility (field count + field types by position), not field names. This allows struct IN subqueries to be offloaded to Velox natively.

  2. VeloxTestSettings.scala — Enable GlutenDataFrameSubquerySuite for Spark 4.1 (was previously disabled with // TODO: 4.x).

Evidence — Spark's join key validation does NOT check struct field names:

Spark HashJoin.scala uses DataType.equalsStructurally (identical in v4.0.1):

require(leftKeys.length == rightKeys.length &&
  leftKeys.map(_.dataType)
    .zip(rightKeys.map(_.dataType))
    .forall(types => DataType.equalsStructurally(types._1, types._2, ignoreNullability = true)),
  "Join keys from two sides should have same length and types")

DataType.equalsStructurally for StructType only compares field count + field types by position — no l.name == r.name:

case (StructType(fromFields), StructType(toFields)) =>
  fromFields.length == toFields.length &&
  fromFields.zip(toFields).forall { case (l, r) =>
    equalsStructurally(l.dataType, r.dataType, ignoreNullability) &&
    (ignoreNullability || l.nullable == r.nullable)
  }

Gluten's sameType() had an extra l.name.equalsIgnoreCase(r.name) check that was more restrictive than Spark's own validation.

How was this patch tested?

  • GlutenDataFrameSubquerySuite on Spark 4.1: all 47 tests passed (struct IN subqueries offloaded to Velox natively)
  • GlutenDataFrameSubquerySuite on Spark 4.0: all 40 tests passed (no regression)

Was this patch authored or co-authored using generative AI tooling?

Generated-by: GitHub Copilot

Related issue: #11550

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions github-actions Bot added the CORE works for Gluten Core label Mar 9, 2026
@baibaichen
baibaichen force-pushed the fix/GlutenDataFrameSubquerySuite branch from 1d56aaa to aab8cd1 Compare March 9, 2026 14:13
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@baibaichen
baibaichen force-pushed the fix/GlutenDataFrameSubquerySuite branch from aab8cd1 to d72f513 Compare March 10, 2026 07:20
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@baibaichen

Copy link
Copy Markdown
Contributor Author

Run Gluten Clickhouse CI on x86

@baibaichen

Copy link
Copy Markdown
Contributor Author

@zhouyuan please review this

Fix struct join key validation to align with Spark's equalsStructurally
semantics. Remove struct field name comparison in sameType() since
Spark's HashJoin only checks structural type compatibility, not field
names. Also catch exceptions during offload attempt in validation
pipeline to allow graceful fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baibaichen
baibaichen force-pushed the fix/GlutenDataFrameSubquerySuite branch from d72f513 to e425d69 Compare March 11, 2026 11:59
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@zhouyuan zhouyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@zhouyuan
zhouyuan merged commit fefdd93 into apache:main Mar 11, 2026
62 checks passed
@baibaichen
baibaichen deleted the fix/GlutenDataFrameSubquerySuite branch March 12, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants