Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
korowa committed May 20, 2024
1 parent fbe15d7 commit 405eb09
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
2 changes: 2 additions & 0 deletions datafusion/sqllogictest/test_files/explain.slt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ logical_plan after single_distinct_aggregation_to_group_by SAME TEXT AS ABOVE
logical_plan after simplify_expressions SAME TEXT AS ABOVE
logical_plan after unwrap_cast_in_comparison SAME TEXT AS ABOVE
logical_plan after common_sub_expression_eliminate SAME TEXT AS ABOVE
logical_plan after eliminate_group_by_constant SAME TEXT AS ABOVE
logical_plan after optimize_projections TableScan: simple_explain_test projection=[a, b, c]
logical_plan after eliminate_nested_union SAME TEXT AS ABOVE
logical_plan after simplify_expressions SAME TEXT AS ABOVE
Expand All @@ -235,6 +236,7 @@ logical_plan after single_distinct_aggregation_to_group_by SAME TEXT AS ABOVE
logical_plan after simplify_expressions SAME TEXT AS ABOVE
logical_plan after unwrap_cast_in_comparison SAME TEXT AS ABOVE
logical_plan after common_sub_expression_eliminate SAME TEXT AS ABOVE
logical_plan after eliminate_group_by_constant SAME TEXT AS ABOVE
logical_plan after optimize_projections SAME TEXT AS ABOVE
logical_plan TableScan: simple_explain_test projection=[a, b, c]
initial_physical_plan CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, c], has_header=true
Expand Down
20 changes: 10 additions & 10 deletions datafusion/sqllogictest/test_files/order.slt
Original file line number Diff line number Diff line change
Expand Up @@ -755,34 +755,34 @@ logical_plan
02)--Union
03)----SubqueryAlias: u
04)------Projection: Int64(0) AS m, m0.t
05)--------Aggregate: groupBy=[[Int64(0), m0.t]], aggr=[[]]
05)--------Aggregate: groupBy=[[m0.t]], aggr=[[]]
06)----------SubqueryAlias: m0
07)------------Projection: column1 AS t
08)--------------Values: (Int64(0)), (Int64(1)), (Int64(2))
09)----SubqueryAlias: v
10)------Projection: Int64(1) AS m, m1.t
11)--------Aggregate: groupBy=[[Int64(1), m1.t]], aggr=[[]]
11)--------Aggregate: groupBy=[[m1.t]], aggr=[[]]
12)----------SubqueryAlias: m1
13)------------Projection: column1 AS t
14)--------------Values: (Int64(0)), (Int64(1))
physical_plan
01)SortPreservingMergeExec: [m@0 ASC NULLS LAST,t@1 ASC NULLS LAST]
02)--SortExec: expr=[m@0 ASC NULLS LAST,t@1 ASC NULLS LAST], preserve_partitioning=[true]
03)----InterleaveExec
04)------ProjectionExec: expr=[Int64(0)@0 as m, t@1 as t]
05)--------AggregateExec: mode=FinalPartitioned, gby=[Int64(0)@0 as Int64(0), t@1 as t], aggr=[], ordering_mode=PartiallySorted([0])
04)------ProjectionExec: expr=[0 as m, t@0 as t]
05)--------AggregateExec: mode=FinalPartitioned, gby=[t@0 as t], aggr=[]
06)----------CoalesceBatchesExec: target_batch_size=8192
07)------------RepartitionExec: partitioning=Hash([Int64(0)@0, t@1], 2), input_partitions=2
07)------------RepartitionExec: partitioning=Hash([t@0], 2), input_partitions=2
08)--------------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
09)----------------AggregateExec: mode=Partial, gby=[0 as Int64(0), t@0 as t], aggr=[], ordering_mode=PartiallySorted([0])
09)----------------AggregateExec: mode=Partial, gby=[t@0 as t], aggr=[]
10)------------------ProjectionExec: expr=[column1@0 as t]
11)--------------------ValuesExec
12)------ProjectionExec: expr=[Int64(1)@0 as m, t@1 as t]
13)--------AggregateExec: mode=FinalPartitioned, gby=[Int64(1)@0 as Int64(1), t@1 as t], aggr=[], ordering_mode=PartiallySorted([0])
12)------ProjectionExec: expr=[1 as m, t@0 as t]
13)--------AggregateExec: mode=FinalPartitioned, gby=[t@0 as t], aggr=[]
14)----------CoalesceBatchesExec: target_batch_size=8192
15)------------RepartitionExec: partitioning=Hash([Int64(1)@0, t@1], 2), input_partitions=2
15)------------RepartitionExec: partitioning=Hash([t@0], 2), input_partitions=2
16)--------------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
17)----------------AggregateExec: mode=Partial, gby=[1 as Int64(1), t@0 as t], aggr=[], ordering_mode=PartiallySorted([0])
17)----------------AggregateExec: mode=Partial, gby=[t@0 as t], aggr=[]
18)------------------ProjectionExec: expr=[column1@0 as t]
19)--------------------ValuesExec

Expand Down
71 changes: 34 additions & 37 deletions datafusion/sqllogictest/test_files/subquery.slt
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,21 @@ logical_plan
03)----TableScan: t1 projection=[t1_id]
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: SUM(t2.t2_int), t2.t2_id
06)--------Aggregate: groupBy=[[t2.t2_id, Utf8("a")]], aggr=[[SUM(CAST(t2.t2_int AS Int64))]]
06)--------Aggregate: groupBy=[[t2.t2_id]], aggr=[[SUM(CAST(t2.t2_int AS Int64))]]
07)----------TableScan: t2 projection=[t2_id, t2_int]
physical_plan
01)ProjectionExec: expr=[t1_id@0 as t1_id, SUM(t2.t2_int)@1 as t2_sum]
01)ProjectionExec: expr=[t1_id@1 as t1_id, SUM(t2.t2_int)@0 as t2_sum]
02)--CoalesceBatchesExec: target_batch_size=2
03)----HashJoinExec: mode=Partitioned, join_type=Left, on=[(t1_id@0, t2_id@1)], projection=[t1_id@0, SUM(t2.t2_int)@1]
04)------CoalesceBatchesExec: target_batch_size=2
05)--------RepartitionExec: partitioning=Hash([t1_id@0], 4), input_partitions=4
06)----------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]
07)------CoalesceBatchesExec: target_batch_size=2
08)--------RepartitionExec: partitioning=Hash([t2_id@1], 4), input_partitions=4
09)----------ProjectionExec: expr=[SUM(t2.t2_int)@2 as SUM(t2.t2_int), t2_id@0 as t2_id]
10)------------AggregateExec: mode=FinalPartitioned, gby=[t2_id@0 as t2_id, Utf8("a")@1 as Utf8("a")], aggr=[SUM(t2.t2_int)], ordering_mode=PartiallySorted([1])
11)--------------CoalesceBatchesExec: target_batch_size=2
12)----------------RepartitionExec: partitioning=Hash([t2_id@0, Utf8("a")@1], 4), input_partitions=4
13)------------------AggregateExec: mode=Partial, gby=[t2_id@0 as t2_id, a as Utf8("a")], aggr=[SUM(t2.t2_int)], ordering_mode=PartiallySorted([1])
14)--------------------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]
03)----HashJoinExec: mode=Partitioned, join_type=Right, on=[(t2_id@1, t1_id@0)], projection=[SUM(t2.t2_int)@0, t1_id@2]
04)------ProjectionExec: expr=[SUM(t2.t2_int)@1 as SUM(t2.t2_int), t2_id@0 as t2_id]
05)--------AggregateExec: mode=FinalPartitioned, gby=[t2_id@0 as t2_id], aggr=[SUM(t2.t2_int)]
06)----------CoalesceBatchesExec: target_batch_size=2
07)------------RepartitionExec: partitioning=Hash([t2_id@0], 4), input_partitions=4
08)--------------AggregateExec: mode=Partial, gby=[t2_id@0 as t2_id], aggr=[SUM(t2.t2_int)]
09)----------------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]
10)------CoalesceBatchesExec: target_batch_size=2
11)--------RepartitionExec: partitioning=Hash([t1_id@0], 4), input_partitions=4
12)----------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]

query II rowsort
SELECT t1_id, (SELECT sum(t2_int) FROM t2 WHERE t2.t2_id = t1.t1_id group by t2_id, 'a') as t2_sum from t1
Expand Down Expand Up @@ -768,8 +766,8 @@ logical_plan
02)--Left Join: t1.t1_int = __scalar_sq_1.t2_int
03)----TableScan: t1 projection=[t1_id, t1_int]
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: COUNT(*), t2.t2_int, __always_true
06)--------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
05)------Projection: COUNT(*), t2.t2_int, Boolean(true) AS __always_true
06)--------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------TableScan: t2 projection=[t2_int]

query II rowsort
Expand All @@ -790,8 +788,8 @@ logical_plan
02)--Left Join: t1.t1_int = __scalar_sq_1.t2_int
03)----TableScan: t1 projection=[t1_id, t1_int]
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: COUNT(*), t2.t2_int, __always_true
06)--------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
05)------Projection: COUNT(*), t2.t2_int, Boolean(true) AS __always_true
06)--------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------TableScan: t2 projection=[t2_int]

query II rowsort
Expand All @@ -811,8 +809,8 @@ logical_plan
02)--Left Join: t1.t1_int = __scalar_sq_1.t2_int
03)----TableScan: t1 projection=[t1_id, t1_int]
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: COUNT(*) AS _cnt, t2.t2_int, __always_true
06)--------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
05)------Projection: COUNT(*) AS _cnt, t2.t2_int, Boolean(true) AS __always_true
06)--------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------TableScan: t2 projection=[t2_int]

query II rowsort
Expand All @@ -832,8 +830,8 @@ logical_plan
02)--Left Join: t1.t1_int = __scalar_sq_1.t2_int
03)----TableScan: t1 projection=[t1_id, t1_int]
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: COUNT(*) + Int64(2) AS _cnt, t2.t2_int, __always_true
06)--------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
05)------Projection: COUNT(*) + Int64(2) AS _cnt, t2.t2_int, Boolean(true) AS __always_true
06)--------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------TableScan: t2 projection=[t2_int]

query II rowsort
Expand All @@ -855,8 +853,8 @@ logical_plan
04)------Left Join: t1.t1_id = __scalar_sq_1.t2_id
05)--------TableScan: t1 projection=[t1_id, t1_int]
06)--------SubqueryAlias: __scalar_sq_1
07)----------Projection: COUNT(*), t2.t2_id, __always_true
08)------------Aggregate: groupBy=[[t2.t2_id, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------Projection: COUNT(*), t2.t2_id, Boolean(true) AS __always_true
08)------------Aggregate: groupBy=[[t2.t2_id]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
09)--------------TableScan: t2 projection=[t2_id]

query I rowsort
Expand All @@ -878,9 +876,8 @@ logical_plan
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: COUNT(*) + Int64(2) AS cnt_plus_2, t2.t2_int
06)--------Filter: COUNT(*) > Int64(1)
07)----------Projection: t2.t2_int, COUNT(*)
08)------------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
09)--------------TableScan: t2 projection=[t2_int]
07)----------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
08)------------TableScan: t2 projection=[t2_int]

query II rowsort
SELECT t1_id, (SELECT count(*) + 2 as cnt_plus_2 FROM t2 WHERE t2.t2_int = t1.t1_int having count(*) >1) from t1
Expand All @@ -900,8 +897,8 @@ logical_plan
02)--Left Join: t1.t1_int = __scalar_sq_1.t2_int
03)----TableScan: t1 projection=[t1_id, t1_int]
04)----SubqueryAlias: __scalar_sq_1
05)------Projection: COUNT(*) + Int64(2) AS cnt_plus_2, t2.t2_int, COUNT(*), __always_true
06)--------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
05)------Projection: COUNT(*) + Int64(2) AS cnt_plus_2, t2.t2_int, COUNT(*), Boolean(true) AS __always_true
06)--------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------TableScan: t2 projection=[t2_int]

query II rowsort
Expand All @@ -924,8 +921,8 @@ logical_plan
05)--------Aggregate: groupBy=[[t1.t1_int]], aggr=[[]]
06)----------TableScan: t1 projection=[t1_int]
07)--------SubqueryAlias: __scalar_sq_1
08)----------Projection: COUNT(*), t2.t2_int, __always_true
09)------------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
08)----------Projection: COUNT(*), t2.t2_int, Boolean(true) AS __always_true
09)------------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
10)--------------TableScan: t2 projection=[t2_int]

query I rowsort
Expand All @@ -945,8 +942,8 @@ logical_plan
04)------Left Join: t1.t1_int = __scalar_sq_1.t2_int
05)--------TableScan: t1 projection=[t1_int]
06)--------SubqueryAlias: __scalar_sq_1
07)----------Projection: COUNT(*) AS cnt, t2.t2_int, __always_true
08)------------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------Projection: COUNT(*) AS cnt, t2.t2_int, Boolean(true) AS __always_true
08)------------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
09)--------------TableScan: t2 projection=[t2_int]


Expand Down Expand Up @@ -975,8 +972,8 @@ logical_plan
04)------Left Join: t1.t1_int = __scalar_sq_1.t2_int
05)--------TableScan: t1 projection=[t1_int]
06)--------SubqueryAlias: __scalar_sq_1
07)----------Projection: COUNT(*) + Int64(1) + Int64(1) AS cnt_plus_two, t2.t2_int, COUNT(*), __always_true
08)------------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------Projection: COUNT(*) + Int64(1) + Int64(1) AS cnt_plus_two, t2.t2_int, COUNT(*), Boolean(true) AS __always_true
08)------------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
09)--------------TableScan: t2 projection=[t2_int]

query I rowsort
Expand Down Expand Up @@ -1004,8 +1001,8 @@ logical_plan
04)------Left Join: t1.t1_int = __scalar_sq_1.t2_int
05)--------TableScan: t1 projection=[t1_int]
06)--------SubqueryAlias: __scalar_sq_1
07)----------Projection: CASE WHEN COUNT(*) = Int64(1) THEN Int64(NULL) ELSE COUNT(*) END AS cnt, t2.t2_int, __always_true
08)------------Aggregate: groupBy=[[t2.t2_int, Boolean(true) AS __always_true]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
07)----------Projection: CASE WHEN COUNT(*) = Int64(1) THEN Int64(NULL) ELSE COUNT(*) END AS cnt, t2.t2_int, Boolean(true) AS __always_true
08)------------Aggregate: groupBy=[[t2.t2_int]], aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
09)--------------TableScan: t2 projection=[t2_int]


Expand Down

0 comments on commit 405eb09

Please sign in to comment.