-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-53738][SQL] PlannedWrite should preserve custom sort order when query output contains literal #52474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-53738][SQL] PlannedWrite should preserve custom sort order when query output contains literal #52474
Changes from 5 commits
a0aa9f4
2a9613b
2a7361c
8fdb230
376e2b6
d439be1
ad09914
0430f18
2b1f8a5
9ace506
7ee4d92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ package org.apache.spark.sql.catalyst.plans | |
| import scala.collection.mutable | ||
|
|
||
| import org.apache.spark.sql.catalyst.SQLConfHelper | ||
| import org.apache.spark.sql.catalyst.expressions.{Alias, Attribute, AttributeSet, Empty2Null, Expression, NamedExpression, SortOrder} | ||
| import org.apache.spark.sql.catalyst.expressions.{Alias, Ascending, Attribute, AttributeSet, Empty2Null, Expression, NamedExpression, SortOrder} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
||
| /** | ||
|
|
@@ -128,6 +128,9 @@ trait AliasAwareQueryOutputOrdering[T <: QueryPlan[T]] | |
| } | ||
| } | ||
| } | ||
| newOrdering.takeWhile(_.isDefined).flatten.toSeq | ||
| newOrdering.takeWhile(_.isDefined).flatten.toSeq ++ outputExpressions.filter { | ||
| case Alias(child, _) => child.foldable | ||
| case expr => expr.foldable | ||
| }.map(SortOrder(_, Ascending).copy(isConstant = true)) | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -487,6 +487,12 @@ case class InMemoryRelation( | |
| cloned | ||
| } | ||
|
|
||
| override def makeCopy(newArgs: Array[AnyRef]): LogicalPlan = { | ||
| val copied = super.makeCopy(newArgs).asInstanceOf[InMemoryRelation] | ||
| copied.statsOfPlanToCache = this.statsOfPlanToCache | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel this is a hidden bug just exposed by this change. |
||
| copied | ||
| } | ||
|
|
||
| override def simpleString(maxFields: Int): String = | ||
| s"InMemoryRelation [${truncatedString(output, ", ", maxFields)}], ${cacheBuilder.storageLevel}" | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.