-
Notifications
You must be signed in to change notification settings - Fork 307
fix: Check sort order of SortExec instead of child output #821
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -2501,10 +2501,7 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim | |
|
|
||
| case SortExec(sortOrder, _, child, _) | ||
| if isCometOperatorEnabled(op.conf, CometConf.OPERATOR_SORT) => | ||
| // TODO: Remove this constraint when we upgrade to new arrow-rs including | ||
| // https://github.com/apache/arrow-rs/pull/6225 | ||
| if (child.output.length == 1 && child.output.head.dataType.isInstanceOf[StructType]) { | ||
| withInfo(op, "Sort on single struct column is not supported") | ||
| if (!supportedSortType(op, sortOrder)) { | ||
| return None | ||
| } | ||
|
|
||
|
|
@@ -3053,4 +3050,15 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim | |
| } | ||
|
|
||
| } | ||
|
|
||
| // TODO: Remove this constraint when we upgrade to new arrow-rs including | ||
| // https://github.com/apache/arrow-rs/pull/6225 | ||
| def supportedSortType(op: SparkPlan, sortOrder: Seq[SortOrder]): Boolean = { | ||
| if (sortOrder.length == 1 && sortOrder.head.dataType.isInstanceOf[StructType]) { | ||
| withInfo(op, "Sort on single struct column is not supported") | ||
|
Comment on lines
+3057
to
+3058
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. As @andygrove mentioned in #811, there are some more types that are not supported. I will add them in other PR. |
||
| false | ||
| } else { | ||
| true | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ import org.apache.spark.sql.execution.metric.SQLMetric | |
| import org.apache.spark.sql.vectorized.ColumnarBatch | ||
|
|
||
| import org.apache.comet.serde.QueryPlanSerde.exprToProto | ||
| import org.apache.comet.serde.QueryPlanSerde.supportedSortType | ||
| import org.apache.comet.shims.ShimCometTakeOrderedAndProjectExec | ||
|
|
||
| /** | ||
|
|
@@ -137,6 +138,6 @@ object CometTakeOrderedAndProjectExec extends ShimCometTakeOrderedAndProjectExec | |
| val exprs = plan.projectList.map(exprToProto(_, plan.child.output)) | ||
| val sortOrders = plan.sortOrder.map(exprToProto(_, plan.child.output)) | ||
| exprs.forall(_.isDefined) && sortOrders.forall(_.isDefined) && getOffset(plan).getOrElse( | ||
| 0) == 0 | ||
| 0) == 0 && supportedSortType(plan, plan.sortOrder) | ||
|
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.
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be the column to sort (i.e., sort order) instead of child output. I made it wrong in #811.