You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# all results
query II
SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc;
----3252251000# limit only
query II
SELECT b, sum(a) FROM ordered_table GROUP BY b order by b descLIMIT3;
----32522510# offset only
query II
SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc OFFSET 1;
----2251000# TODO: fix this to properly apply offset# offset + limit
query II
SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc OFFSET 1LIMIT2;
----32522510# TODO: fix this to not remove the skip=1 during the limit pushdown# Applying offset & limit when multiple streams from groupby
query TT
EXPLAIN SELECT b, sum(a) FROM ordered_table GROUP BY b order by b desc OFFSET 1LIMIT2;
----
logical_plan
01)Limit: skip=1, fetch=202)--Sort: ordered_table.b DESC NULLS FIRST, fetch=303)----Aggregate: groupBy=[[ordered_table.b]], aggr=[[sum(CAST(ordered_table.a AS Int64))]]04)------TableScan: ordered_table projection=[a, b]
physical_plan
01)SortPreservingMergeExec: [b@0DESC], fetch=302)--SortExec: TopK(fetch=3), expr=[b@0 DESC], preserve_partitioning=[true]03)----AggregateExec: mode=FinalPartitioned, gby=[b@0 as b], aggr=[sum(ordered_table.a)]04)------CoalesceBatchesExec: target_batch_size=819205)--------RepartitionExec: partitioning=Hash([b@0], 2), input_partitions=206)----------AggregateExec: mode=Partial, gby=[b@1 as b], aggr=[sum(ordered_table.a)]07)------------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=108)--------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a, b], has_header=true# TODO: fix this to not remove the skip=4 during the limit pushdown# Applying offset & limit when multiple streams from union
query TT
explain select*FROM (
select c FROM ordered_table
UNION ALLselect d FROM ordered_table
) order by1descLIMIT10 OFFSET 4;
----
logical_plan
01)Limit: skip=4, fetch=1002)--Sort: ordered_table.c DESC NULLS FIRST, fetch=1403)----Union04)------Projection: CAST(ordered_table.c AS Int64) AS c05)--------TableScan: ordered_table projection=[c]06)------Projection: CAST(ordered_table.d AS Int64) AS c07)--------TableScan: ordered_table projection=[d]
physical_plan
01)SortPreservingMergeExec: [c@0DESC], fetch=1402)--UnionExec03)----SortExec: TopK(fetch=14), expr=[c@0 DESC], preserve_partitioning=[true]04)------ProjectionExec: expr=[CAST(c@0 AS Int64) as c]05)--------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=106)----------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[c], output_ordering=[c@0 ASC NULLS LAST], has_header=true07)----SortExec: TopK(fetch=14), expr=[c@0 DESC], preserve_partitioning=[true]08)------ProjectionExec: expr=[CAST(d@0 AS Int64) as c]09)--------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=110)----------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[d], has_header=true# ApplyingmLIMIT & OFFSET to subquery.
query III
selectt1.b, c, c2 FROM (
select b, c FROM ordered_table ORDER BY b desc, c desc OFFSET 1LIMIT4
) as t1 INNER JOIN (
select b, c as c2 FROM ordered_table ORDER BY b desc, d desc OFFSET 1LIMIT4
) as t2
ONt1.b=t2.bORDER BYt1.bdesc, c desc, c2 desc;
----39896398893988239879397963978939782397793969639689396823967939596395893958239579# TODO: fix this does not correctly work.# Apply OFFSET & LIMIT to both parent and child (subquery).
query III
selectt1.b, c, c2 FROM (
select b, c FROM ordered_table ORDER BY b desc, c desc OFFSET 1LIMIT4
) as t1 INNER JOIN (
select b, c as c2 FROM ordered_table ORDER BY b desc, d desc OFFSET 1LIMIT4
) as t2
ONt1.b=t2.bORDER BYt1.bdesc, c desc, c2 desc
OFFSET 3LIMIT2;
----3999639989399873998239979
Expected behavior
Query should not lose the offset
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
#12003 introduced a bug where sometimes the
OFFSET
clause is accidentally removedI am filing this ticket to track the regression / know it exists
To Reproduce
@wiedld created a reproducer here b6fd751
Add this to the
order.slt
file:Expected behavior
Query should not lose the offset
Additional context
No response
The text was updated successfully, but these errors were encountered: