LuciferYang commented on code in PR #13726:
URL: https://github.com/apache/gluten/pull/13726#discussion_r4691684416
##########
backends-velox/src-delta33/main/scala/org/apache/spark/sql/delta/files/GlutenDeltaFileFormatWriter.scala:
##########
@@ -256,37 +256,33 @@ object GlutenDeltaFileFormatWriter extends LoggingShims {
if (projectList.nonEmpty) ProjectExecTransformer(projectList, plan) else
plan
writeAndCommit(job, description, committer) {
- val (planToExecute, concurrentOutputWriterSpec) = if (orderingMatched) {
- (empty2NullPlan, None)
+ def collapseStages(input: SparkPlan): SparkPlan =
+ GenerateTransformStageId()(
+ ColumnarCollapseTransformStages(new
GlutenConfig(sparkSession.sessionState.conf))(input))
+ // Spark's concurrent output writers read the partition values of every
row, which a
+ // BatchCarrierRow doesn't expose, so always sort by partition, as when
+ // spark.sql.maxConcurrentOutputFileWriters is 0.
+ val planToExecute = if (orderingMatched) {
+ // The empty-to-null project is a bare transformer, which can't run
outside a stage.
+ if (projectList.nonEmpty) collapseStages(empty2NullPlan) else
empty2NullPlan
Review Comment:
Fixed in 7524d0d2e. The writer now skips its sort only if the partition
values stay grouped after Empty2Null: no partition column goes through it, or
only the last one does and the input sorts it ASC NULLS FIRST or DESC NULLS
LAST, which already puts null and "" together. `isOrderingMatched` ignores
direction and null ordering, so the check reads the input's `SortOrder` for
that column. Both writers have the same check.
The new test in both suites runs one task with one row per batch and checks
the committed files per partition and whether the writer added a sort. Your
`(s, p)` example, `s` ASC NULLS LAST, `s` DESC NULLS FIRST and `(p, s ASC NULLS
LAST)` get the writer's sort; `s`, `s` DESC NULLS LAST and `(p, s)` don't. With
the previous head, the first four commit extra files on Spark 3.5 and 4.1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]