Skip to content

Commit

Permalink
minor: port predicates tests to sqllogictests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Feb 25, 2023
1 parent cef194c commit 6276d4c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 50 deletions.
1 change: 0 additions & 1 deletion datafusion/core/src/datasource/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ mod tests {
let formatted = arrow::util::pretty::pretty_format_batches(&plan)
.unwrap()
.to_string();
println!("{}", formatted);
assert!(formatted.contains("ParquetExec: limit=Some(10)"));
Ok(())
}
Expand Down
24 changes: 8 additions & 16 deletions datafusion/core/tests/sql/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@ async fn union_with_except_input() -> Result<()> {
" Union [name:UInt8;N]",
" LeftAnti Join: t1.name = t2.name [name:UInt8;N]",
" Aggregate: groupBy=[[t1.name]], aggr=[[]] [name:UInt8;N]",
" Projection: t1.name [name:UInt8;N]",
" TableScan: t1 projection=[name] [name:UInt8;N]",
" Projection: t2.name [name:UInt8;N]",
" TableScan: t2 projection=[name] [name:UInt8;N]",
" TableScan: t1 projection=[name] [name:UInt8;N]",
" TableScan: t2 projection=[name] [name:UInt8;N]",
" LeftAnti Join: t2.name = t1.name [name:UInt8;N]",
" Aggregate: groupBy=[[t2.name]], aggr=[[]] [name:UInt8;N]",
" Projection: t2.name [name:UInt8;N]",
" TableScan: t2 projection=[name] [name:UInt8;N]",
" Projection: t1.name [name:UInt8;N]",
" TableScan: t1 projection=[name] [name:UInt8;N]",
" TableScan: t2 projection=[name] [name:UInt8;N]",
" TableScan: t1 projection=[name] [name:UInt8;N]",
];

let formatted = plan.display_indent_schema().to_string();
Expand Down Expand Up @@ -82,17 +78,13 @@ async fn union_with_type_coercion() -> Result<()> {
" Union [id:Int32;N, name:UInt8;N]",
" LeftAnti Join: t1.id = CAST(t2.id AS Int32), t1.name = t2.name [id:Int32;N, name:UInt8;N]",
" Aggregate: groupBy=[[t1.id, t1.name]], aggr=[[]] [id:Int32;N, name:UInt8;N]",
" Projection: t1.id, t1.name [id:Int32;N, name:UInt8;N]",
" TableScan: t1 projection=[id, name] [id:Int32;N, name:UInt8;N]",
" Projection: t2.id, t2.name [id:UInt8;N, name:UInt8;N]",
" TableScan: t2 projection=[id, name] [id:UInt8;N, name:UInt8;N]",
" TableScan: t1 projection=[id, name] [id:Int32;N, name:UInt8;N]",
" TableScan: t2 projection=[id, name] [id:UInt8;N, name:UInt8;N]",
" Projection: CAST(t2.id AS Int32) AS id, t2.name [id:Int32;N, name:UInt8;N]",
" LeftAnti Join: CAST(t2.id AS Int32) = t1.id, t2.name = t1.name [id:UInt8;N, name:UInt8;N]",
" Aggregate: groupBy=[[t2.id, t2.name]], aggr=[[]] [id:UInt8;N, name:UInt8;N]",
" Projection: t2.id, t2.name [id:UInt8;N, name:UInt8;N]",
" TableScan: t2 projection=[id, name] [id:UInt8;N, name:UInt8;N]",
" Projection: t1.id, t1.name [id:Int32;N, name:UInt8;N]",
" TableScan: t1 projection=[id, name] [id:Int32;N, name:UInt8;N]",
" TableScan: t2 projection=[id, name] [id:UInt8;N, name:UInt8;N]",
" TableScan: t1 projection=[id, name] [id:Int32;N, name:UInt8;N]",
];
let formatted = plan.display_indent_schema().to_string();
let actual: Vec<&str> = formatted.trim().lines().collect();
Expand Down
5 changes: 2 additions & 3 deletions datafusion/core/tests/sqllogictests/test_files/explain.slt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ query TT
EXPLAIN select count(*) from (values ('a', 1, 100), ('a', 2, 150)) as t (c1,c2,c3)
----
physical_plan
ProjectionExec: expr=[COUNT(UInt8(1))@0 as COUNT(UInt8(1))]
ProjectionExec: expr=[2 as COUNT(UInt8(1))]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[2 as COUNT(UInt8(1))]
EmptyExec: produce_one_row=true

statement ok
set datafusion.explain.physical_plan_only = false
Expand Down
42 changes: 20 additions & 22 deletions datafusion/core/tests/sqllogictests/test_files/window.slt
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,17 @@ Sort: d.b ASC NULLS LAST
Aggregate: groupBy=[[d.b]], aggr=[[MAX(d.a)]]
SubqueryAlias: d
SubqueryAlias: _data2
Projection: s.a, s.b
SubqueryAlias: s
SubqueryAlias: _sample_data
Union
Projection: Int64(1) AS a, Utf8("aa") AS b
EmptyRelation
Projection: Int64(3) AS a, Utf8("aa") AS b
EmptyRelation
Projection: Int64(5) AS a, Utf8("bb") AS b
EmptyRelation
Projection: Int64(7) AS a, Utf8("bb") AS b
EmptyRelation
SubqueryAlias: s
SubqueryAlias: _sample_data
Union
Projection: Int64(1) AS a, Utf8("aa") AS b
EmptyRelation
Projection: Int64(3) AS a, Utf8("aa") AS b
EmptyRelation
Projection: Int64(5) AS a, Utf8("bb") AS b
EmptyRelation
Projection: Int64(7) AS a, Utf8("bb") AS b
EmptyRelation
physical_plan
SortPreservingMergeExec: [b@0 ASC NULLS LAST]
SortExec: expr=[b@0 ASC NULLS LAST]
Expand All @@ -278,16 +277,15 @@ SortPreservingMergeExec: [b@0 ASC NULLS LAST]
CoalesceBatchesExec: target_batch_size=8192
RepartitionExec: partitioning=Hash([Column { name: "b", index: 0 }], 4), input_partitions=4
AggregateExec: mode=Partial, gby=[b@1 as b], aggr=[MAX(d.a)]
ProjectionExec: expr=[a@0 as a, b@1 as b]
UnionExec
ProjectionExec: expr=[1 as a, aa as b]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[3 as a, aa as b]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[5 as a, bb as b]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[7 as a, bb as b]
EmptyExec: produce_one_row=true
UnionExec
ProjectionExec: expr=[1 as a, aa as b]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[3 as a, aa as b]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[5 as a, bb as b]
EmptyExec: produce_one_row=true
ProjectionExec: expr=[7 as a, bb as b]
EmptyExec: produce_one_row=true

# Check actual result:
query TI
Expand Down
13 changes: 5 additions & 8 deletions datafusion/substrait/tests/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,11 @@ mod tests {
async fn simple_intersect() -> Result<()> {
assert_expected_plan(
"SELECT COUNT(*) FROM (SELECT data.a FROM data INTERSECT SELECT data2.a FROM data2);",
"Projection: COUNT(Int16(1))\
\n Aggregate: groupBy=[[]], aggr=[[COUNT(Int16(1))]]\
\n LeftSemi Join: data.a = data2.a\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
\n Projection: data.a\
\n TableScan: data projection=[a]\
\n Projection: data2.a\
\n TableScan: data2 projection=[a]",
"Aggregate: groupBy=[[]], aggr=[[COUNT(Int16(1))]]\
\n LeftSemi Join: data.a = data2.a\
\n Aggregate: groupBy=[[data.a]], aggr=[[]]\
\n TableScan: data projection=[a]\
\n TableScan: data2 projection=[a]",
)
.await
}
Expand Down

0 comments on commit 6276d4c

Please sign in to comment.