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

Port tests in limit.rs to sqllogictest #8315

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 0 additions & 101 deletions datafusion/core/tests/sql/limit.rs

This file was deleted.

104 changes: 104 additions & 0 deletions datafusion/sqllogictest/test_files/limit.slt
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,110 @@ SELECT COUNT(*) FROM (SELECT a FROM t1 WHERE a > 3 LIMIT 3 OFFSET 6);
----
1

# generate BIGINT data from 1 to 1000
statement ok
CREATE TABLE t1000 (i BIGINT) AS
WITH t AS (VALUES (0), (0), (0), (0), (0), (0), (0), (0), (0), (0))
SELECT ROW_NUMBER() OVER (PARTITION BY t1.column1) FROM t t1, t t2, t t3;
Copy link
Contributor

Choose a reason for hiding this comment

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

I double checked that this actually generates partitioned input and it does indeed.

You can see on my local setup that the MemoryExec has multiple partitions

❯ explain select distinct i  from t1000;
+---------------+-----------------------------------------------------------------------------------------------------+
| plan_type     | plan                                                                                                |
+---------------+-----------------------------------------------------------------------------------------------------+
| logical_plan  | Aggregate: groupBy=[[t1000.i]], aggr=[[]]                                                           |
|               |   TableScan: t1000 projection=[i]                                                                   |
| physical_plan | AggregateExec: mode=FinalPartitioned, gby=[i@0 as i], aggr=[]                                       |
|               |   CoalesceBatchesExec: target_batch_size=8192                                                       |
|               |     RepartitionExec: partitioning=Hash([i@0], 16), input_partitions=16                              |
|               |       AggregateExec: mode=Partial, gby=[i@0 as i], aggr=[]                                          |
|               |         MemoryExec: partitions=16, partition_sizes=[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1] |
|               |                                                                                                     |
+---------------+-----------------------------------------------------------------------------------------------------+

Copy link
Contributor

Choose a reason for hiding this comment

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

I took the liberty of updating some comments / adding an explain tests in 26510c9


query I
SELECT i FROM t1000 ORDER BY i DESC LIMIT 3;
----
1000
999
998

query I
SELECT i FROM t1000 ORDER BY i LIMIT 3;
----
1
2
3

query I
SELECT COUNT(*) FROM (SELECT i FROM t1000 LIMIT 3);
----
3

# limit_multi_partitions
statement ok
CREATE TABLE t15 (i BIGINT);

query I
INSERT INTO t15 VALUES (1);
----
1

query I
INSERT INTO t15 VALUES (1), (2);
----
2

query I
INSERT INTO t15 VALUES (1), (2), (3);
----
3

query I
INSERT INTO t15 VALUES (1), (2), (3), (4);
----
4

query I
INSERT INTO t15 VALUES (1), (2), (3), (4), (5);
----
5

query I
SELECT COUNT(*) FROM t15;
----
15

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 1);
----
1

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 2);
----
2

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 3);
----
3

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 4);
----
4

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 5);
----
5

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 6);
----
6

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 7);
----
7

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 8);
----
8

query I
SELECT COUNT(*) FROM (SELECT i FROM t15 LIMIT 9);
----
9

########
# Clean up after the test
########
Expand Down
Loading