[ 
https://issues.apache.org/jira/browse/SPARK-62263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated SPARK-62263:
-----------------------------------
    Labels: pull-request-available  (was: )

> Do not map foldable aliases in AliasAwareOutputExpression
> ---------------------------------------------------------
>
>                 Key: SPARK-62263
>                 URL: https://issues.apache.org/jira/browse/SPARK-62263
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 5.0.0
>            Reporter: XiDuo You
>            Priority: Major
>              Labels: pull-request-available
>
> `AliasAwareOutputExpression.aliasMap` treats every `Alias(child, _)` as a 
> column identity, including a foldable child such as `1 AS one`. 
> `projectExpression` then replaces the literal inside the child's inherited 
> partitioning/ordering expressions with the alias attribute and drops the 
> original expression (`a + 1` -> `a + one`), so the projection no longer 
> satisfies a requirement on `a + 1` and the planner inserts a redundant 
> exchange (or sort).
> Repro (Int key, AQE and broadcast disabled):
>     val base = spark.range(10).selectExpr("cast(id as int) as a")
>     val left = base.repartition($"a" + 1).selectExpr("a", "1 as one")
>     val right = base.selectExpr("a as k")
>     left.join(right, left("a") + 1 === right("k"))
> The left side is shuffled twice with `hashpartitioning(a + 1)` (3 shuffles). 
> After the fix it reuses the user's repartition (2 shuffles).
> Fix: skip foldable children when building the alias map. A constant carries 
> no column identity to project.
> Affects 3.5.0 and later (the alias map was introduced by SPARK-42049).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to