alamb commented on issue #12446:
URL: https://github.com/apache/datafusion/issues/12446#issuecomment-2361894958
I spent some time finding a smaller standalone reproducer
```sql
create table t(a0 int, a int, b int, c int) as values (1, 2, 3, 4), (5, 6,
7, 8);
select * from (select c, a, NULL::int as a0 from t order by a, c) t1
union all
select * from (select c, NULL::int as a, a0 from t order by a0, c) t2
order by c, a, a0, b
limit 2;
```
When run
```sql
> select * from (select c, a, NULL::int as a0 from t order by a, c) t1
union all
select * from (select c, NULL::int as a, a0 from t order by a0, c) t2
order by c, a, a0, b
limit 2;
SanityCheckPlan
caused by
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:
[PhysicalSortRequirement { expr: Column { name: "c", index: 0 }, options:
Some(SortOptions { descending: false, nulls_first: false }) },
PhysicalSortRequirement { expr: Column { name: "a", index: 1 }, options:
Some(SortOptions { descending: false, nulls_first: false }) }, Physical
SortRequirement { expr: Column { name: "a0", index: 2 }, options:
Some(SortOptions { descending: false, nulls_first: false }) },
PhysicalSortRequirement { expr: Column { name: "b", index: 3 }, options:
Some(SortOptions { descending: false, nulls_first: false }) }]. Child-0 order:
OrderingEquivalenceClass { orderings: [[PhysicalSortExpr { expr: Column { name:
"c", index: 0 }, options: SortOptions { descending: false, nulls_first: false }
}, PhysicalSortExpr { expr: Column { name: "a", index: 1 }, options:
SortOptions { descending: false, nulls_first: false } }], [PhysicalSortExpr {
expr: Column { name: "c", index: 0 }, options: SortOptions { descending: false,
nulls_first: false } }, PhysicalSortExpr { expr: Column { name: "a0", index: 2
}, options: SortOptions { descending: false, nulls_first: false } }]] }
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]