Skip to content

fix: Check sort order of SortExec instead of child output#821

Merged
viirya merged 2 commits intoapache:mainfrom
viirya:fix_sort2
Aug 13, 2024
Merged

fix: Check sort order of SortExec instead of child output#821
viirya merged 2 commits intoapache:mainfrom
viirya:fix_sort2

Conversation

@viirya
Copy link
Copy Markdown
Member

@viirya viirya commented Aug 13, 2024

Which issue does this PR close?

Closes #822.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

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]) {
Copy link
Copy Markdown
Member Author

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.

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)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CometTakeOrderedAndProjectExec will invoke DataFusion SortExec operator, so we should also check for it.

@viirya viirya requested a review from huaxingao August 13, 2024 07:26
Comment on lines +3057 to +3058
if (sortOrder.length == 1 && sortOrder.head.dataType.isInstanceOf[StructType]) {
withInfo(op, "Sort on single struct column is not supported")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

@viirya viirya merged commit 81af72f into apache:main Aug 13, 2024
@viirya
Copy link
Copy Markdown
Member Author

viirya commented Aug 13, 2024

Thanks @andygrove @huaxingao

@viirya viirya deleted the fix_sort2 branch August 13, 2024 16:18
himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
* fix: Check sort order of SortExec instead of child output

* Remove unused import

(cherry picked from commit 81af72f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check sort order of SortExec instead of child output

3 participants