Skip to content

[GLUTEN-12555][CORE] Propagate child outputPartitioning and outputOrdering in ColumnarToColumnarExec#12556

Open
wangyum wants to merge 1 commit into
apache:mainfrom
wangyum:fix/columnar-to-columnar-output-properties
Open

[GLUTEN-12555][CORE] Propagate child outputPartitioning and outputOrdering in ColumnarToColumnarExec#12556
wangyum wants to merge 1 commit into
apache:mainfrom
wangyum:fix/columnar-to-columnar-output-properties

Conversation

@wangyum

@wangyum wangyum commented Jul 18, 2026

Copy link
Copy Markdown
Member

What changes are included in this PR?

ColumnarToColumnarExec now propagates the child's outputPartitioning and outputOrdering instead of inheriting the defaults (UnknownPartitioning / Nil) from SparkPlan via UnaryExecNode.

override def outputPartitioning: Partitioning = child.outputPartitioning

override def outputOrdering: Seq[SortOrder] = child.outputOrdering

plus the required Partitioning / SortOrder imports.

Why are the changes needed?

ColumnarToColumnarExec (in gluten-core) is the abstract base for operators that only reshape / resize / convert columnar batches without altering row distribution or order. Concrete subclasses include VeloxResizeBatchesExec, ArrowColumnarToVeloxColumnarExec, OffloadArrowDataExec, LoadArrowDataExec, and GpuResizeBufferColumnarBatchExec.

Previously these wrappers reported UnknownPartitioning(numColumns) and Nil ordering, which misrepresents the physical layout. Consequences:

  • Storage-partitioned joins / v2 bucketing are not recognized when a batch-resize or format-convert node sits between a BatchScanExec (reporting KeyGroupedPartitioning) and the join, so the planner inserts a redundant shuffle, defeating the scan-reported partitioning.
  • SortMergeJoin plans lose the child's sort order across the wrapper and insert an extra Sort.
  • More generally, exchange reuse / AQE coalescing / ordering-based optimizations make suboptimal decisions whenever one of these wrappers is present.

This mirrors how vanilla Spark's ColumnarToRowExec / RowToColumnarExec and Gluten's own ColumnarInputAdapter treat partitioning/ordering transparency. It applies to all supported Spark versions and all backends.

Closes #12555.

Does this PR introduce any user-facing change?

No API change. Plans that previously inserted a redundant shuffle / sort around a columnar reshape can become more efficient.

How was this patch tested?

Existing unit tests (no behavioral change to data, only to plan shape); relied on the fact that the wrappers are data-transparent. Follow-up: a plan-shape assertion test for SPJ through a resize node can be added if reviewers want explicit coverage.

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

Yes.
Generated-by: opencode GLM 5.2

…ering in ColumnarToColumnarExec

ColumnarToColumnarExec is the abstract base for operators that only reshape,
resize, or convert columnar batches without altering row distribution or order
(e.g. VeloxResizeBatchesExec, ArrowColumnarToVeloxColumnarExec,
OffloadArrowDataExec, LoadArrowDataExec, GpuResizeBufferColumnarBatchExec).

It previously inherited the default outputPartitioning (UnknownPartitioning)
and outputOrdering (Nil) from SparkPlan via UnaryExecNode, misrepresenting the
physical layout. As a result:
- storage-partitioned joins / v2 bucketing were not recognized when a
  batch-resize or format-convert node sat between a BatchScanExec and the
  join, causing a redundant shuffle;
- SortMergeJoin lost the child's sort order across the wrapper and inserted
  an extra Sort;
- exchange reuse / AQE coalescing / ordering-based optimizations made
  suboptimal decisions.

Propagate the child's partitioning and ordering so the wrapper is transparent
to the physical planner, mirroring how vanilla Spark's ColumnarToRowExec /
RowToColumnarExec and Gluten's ColumnarInputAdapter handle transparency.

Closes apache#12555.

Generated-by: opencode ebay-glm-5-2-fp8-chat
Copilot AI review requested due to automatic review settings July 18, 2026 15:06
@github-actions github-actions Bot added the CORE works for Gluten Core label Jul 18, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ColumnarToColumnarExec (the core base class for columnar “transparent” wrapper operators) to correctly propagate physical properties from its child plan node, so Spark’s planner/AQE can continue to recognize existing distribution and ordering through these wrappers.

Changes:

  • Propagate outputPartitioning from child.outputPartitioning in ColumnarToColumnarExec.
  • Propagate outputOrdering from child.outputOrdering in ColumnarToColumnarExec.
  • Add the required Spark SQL imports (Partitioning, SortOrder) to support these overrides.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

ColumnarToColumnarExec loses child outputPartitioning and outputOrdering

2 participants