Skip to content
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

Improve SanityChecker error message #12595

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Sep 23, 2024

Which issue does this PR close?

Part of #12446

Rationale for this change

Today when the SanityChecker fails it is not always clear why and dumps out a message like thisL

Error during planning: Plan: ["SortPreservingMergeExec: [d@4 ASC NULLS LAST,c@1 ASC NULLS LAST,a@2 ASC NULLS LAST,a0@3 ASC NULLS LAST,b@0 ASC NULLS LAST], fetch=2", " UnionExec", " SortExec: TopK(fetch=2), expr=[d@4 ASC NULLS LAST,c@1 ASC NULLS LAST,a@2 ASC NULLS LAST,b@0 ASC NULLS LAST], preserve_partitioning=[false]", " ProjectionExec: expr=[b@1 as b, c@2 as c, a@0 as a, NULL as a0, d@3 as d]", " CsvExec: file_groups={1 group: [[Users/andrewlamb/Software/datafusion2/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b, c, d], output_ordering=[c@2 ASC NULLS LAST], has_header=true", " SortExec: TopK(fetch=2), expr=[d@4 ASC NULLS LAST,c@1 ASC NULLS LAST,a0@3 ASC NULLS LAST,b@0 ASC NULLS LAST], preserve_partitioning=[false]", " ProjectionExec: expr=[b@1 as b, c@2 as c, NULL as a, a0@0 as a0, d@3 as d]", " CsvExec: file_groups={1 group: [[Users/andrewlamb/Software/datafusion2/datafusion/core/tests/data/window_2.csv]]}, projection=[a0, b, c, d], output_ordering=[c@2 ASC NULLS LAST], has_header=true"] does not satisfy order requirements: [PhysicalSortRequirement { expr: Column { name: "d", index: 4 }, options: Some(SortOptions { descending: false, nulls_first: false }) }, PhysicalSortRequirement { expr: Column { name: "c", index: 1 }, options: Some(SortOptions { descending: false, nulls_first: false }) }, PhysicalSortRequirement { expr: Column { name: "a", index: 2 }, options: Some(SortOptions { descending: false, nulls_first: false }) }, PhysicalSortRequirement { expr: Column { name: "a0", index: 3 }, options: Some(SortOptions { descending: false, nulls_first: false }) }, PhysicalSortRequirement { expr: Column { name: "b", index: 0 }, options: Some(SortOptions { descending: false, nulls_first: false }) }]. Child-0 order: OrderingEquivalenceClass { orderings: [[PhysicalSortExpr { expr: Column { name: "d", index: 4 }, options: SortOptions { descending: false, nulls_first: false } }, PhysicalSortExpr { expr: Column { name: "c", index: 1 }, options: SortOptions { descending: false, nulls_first: false } }]] }

It would be nice to at least have the actual and required ordering dumped out in readable form

What changes are included in this PR?

Improve the display of the actual and required ordering in the error message
Here is an example of what the output looks liek now:

Error during planning: Plan: ["SortPreservingMergeExec: [c@0 ASC NULLS LAST,a@1 ASC NULLS LAST,a0@2 ASC NULLS LAST,b@3 ASC NULLS LAST], fetch=2", " UnionExec", " SortExec: TopK(fetch=2), expr=[c@0 ASC NULLS LAST,a@1 ASC NULLS LAST,b@3 ASC NULLS LAST], preserve_partitioning=[false]", " ProjectionExec: expr=[c@2 as c, a@0 as a, NULL as a0, b@1 as b]", " MemoryExec: partitions=1, partition_sizes=[1]", " SortExec: TopK(fetch=2), expr=[c@0 ASC NULLS LAST,a0@2 ASC NULLS LAST,b@3 ASC NULLS LAST], preserve_partitioning=[false]", " ProjectionExec: expr=[c@2 as c, NULL as a, a0@0 as a0, b@1 as b]", " MemoryExec: partitions=1, partition_sizes=[1]"] does not satisfy order requirements: [c@0 ASC NULLS LAST, a@1 ASC NULLS LAST, a0@2 ASC NULLS LAST, b@3 ASC NULLS LAST]. Child-0 order: [[c@0 ASC NULLS LAST]]

Specifically I think the part is now useful:

does not satisfy order requirements: [c@0 ASC NULLS LAST, a@1 ASC NULLS LAST, a0@2 ASC NULLS LAST, b@3 ASC NULLS LAST]. Child-0 order: [[c@0 ASC NULLS LAST]]

Are these changes tested?

Are there any user-facing changes?

@alamb alamb force-pushed the alamb/sanity_checker_message branch from 8aac9b4 to 53f2479 Compare September 24, 2024 14:52
@alamb alamb marked this pull request as ready for review September 24, 2024 16:33
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm thanks @alamb wondering why no tests are failing 🤔

@alamb
Copy link
Contributor Author

alamb commented Sep 25, 2024

lgtm thanks @alamb wondering why no tests are failing 🤔

Its because this error only happens due to bugs (like #12446) so in theory it "shouldn't be able to be hit" 😆

@alamb alamb merged commit 21df68c into apache:main Sep 25, 2024
25 checks passed
@alamb
Copy link
Contributor Author

alamb commented Sep 25, 2024

Thank you for the review @comphead

@alamb alamb deleted the alamb/sanity_checker_message branch September 25, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants