Skip to content

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

Open
baibaichen wants to merge 1 commit intoapache:mainfrom
baibaichen:fix/GlutenDataFrameSubquerySuite
Open

[GLUTEN-11550][VL] Enable GlutenDataFrameSubquerySuite for Spark 4.1#11727
baibaichen wants to merge 1 commit intoapache:mainfrom
baibaichen:fix/GlutenDataFrameSubquerySuite

Conversation

@baibaichen
Copy link
Contributor

@baibaichen baibaichen commented Mar 9, 2026

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
Copy link

github-actions bot commented Mar 9, 2026

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
Copy link

github-actions bot commented Mar 9, 2026

Run Gluten Clickhouse CI on x86

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 aab8cd1 to d72f513 Compare March 10, 2026 07:20
@github-actions
Copy link

Run Gluten Clickhouse CI on x86

1 similar comment
@baibaichen
Copy link
Contributor Author

Run Gluten Clickhouse CI on x86

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.

1 participant