You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2020/06/29 04:57:18 UTC
[spark] branch branch-3.0 updated: [SPARK-32038][SQL][FOLLOWUP]
Make the alias name pretty after float/double normalization
This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new a00470d [SPARK-32038][SQL][FOLLOWUP] Make the alias name pretty after float/double normalization
a00470d is described below
commit a00470d583d1f53a7f5f440be2b0a5fefd35fcec
Author: Wenchen Fan <we...@databricks.com>
AuthorDate: Sun Jun 28 21:55:19 2020 -0700
[SPARK-32038][SQL][FOLLOWUP] Make the alias name pretty after float/double normalization
### What changes were proposed in this pull request?
This is a followup of https://github.com/apache/spark/pull/28876/files
This PR proposes to use the name of the original expression, as the alias name of the normalization expression.
### Why are the changes needed?
make the query plan looks pretty when EXPLAIN.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
manually explain the query
Closes #28919 from cloud-fan/follow.
Authored-by: Wenchen Fan <we...@databricks.com>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
(cherry picked from commit 835ef425d03f30984e885448fe785905ed1ee9a7)
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
.../scala/org/apache/spark/sql/execution/SparkStrategies.scala | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
index 10cd7b6..a983bc8 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
@@ -527,6 +527,7 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
val normalizedGroupingExpressions = groupingExpressions.map { e =>
NormalizeFloatingNumbers.normalize(e) match {
case n: NamedExpression => n
+ // Keep the name of the original expression.
case other => Alias(other, e.name)(exprId = e.exprId)
}
}
@@ -551,7 +552,13 @@ abstract class SparkStrategies extends QueryPlanner[SparkPlan] {
// because `distinctExpressions` is not extracted during logical phase.
NormalizeFloatingNumbers.normalize(e) match {
case ne: NamedExpression => ne
- case other => Alias(other, other.toString)()
+ case other =>
+ // Keep the name of the original expression.
+ val name = e match {
+ case ne: NamedExpression => ne.name
+ case _ => e.toString
+ }
+ Alias(other, name)()
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org