Skip to content

Commit 15bbe4a

Browse files
committed
Add insta tests
1 parent 8ad047c commit 15bbe4a

2 files changed

Lines changed: 50 additions & 52 deletions

File tree

datafusion/core/tests/dataframe/mod.rs

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,31 +3429,30 @@ async fn test_count_wildcard_on_where_scalar_subquery() -> Result<()> {
34293429
assert_snapshot!(
34303430
pretty_format_batches(&sql_results).unwrap(),
34313431
@r"
3432-
+---------------+----------------------------------------------------------------------------------------------------------------------------+
3433-
| plan_type | plan |
3434-
+---------------+----------------------------------------------------------------------------------------------------------------------------+
3435-
| logical_plan | Projection: t1.a, t1.b |
3436-
| | Filter: CASE WHEN __scalar_sq_1.__always_true IS NULL THEN Int64(0) ELSE __scalar_sq_1.count(*) END > Int64(0) |
3437-
| | Projection: t1.a, t1.b, __scalar_sq_1.count(*), __scalar_sq_1.__always_true |
3438-
| | Left Join: t1.a = __scalar_sq_1.a |
3439-
| | TableScan: t1 projection=[a, b] |
3440-
| | SubqueryAlias: __scalar_sq_1 |
3441-
| | Projection: count(Int64(1)) AS count(*), t2.a, Boolean(true) AS __always_true |
3442-
| | Aggregate: groupBy=[[t2.a]], aggr=[[count(Int64(1))]] |
3443-
| | TableScan: t2 projection=[a] |
3444-
| physical_plan | FilterExec: CASE WHEN __always_true@3 IS NULL THEN 0 ELSE count(*)@2 END > 0, projection=[a@0, b@1] |
3445-
| | RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 |
3446-
| | ProjectionExec: expr=[a@2 as a, b@3 as b, count(*)@0 as count(*), __always_true@1 as __always_true] |
3447-
| | HashJoinExec: mode=CollectLeft, join_type=Right, on=[(a@1, a@0)], projection=[count(*)@0, __always_true@2, a@3, b@4] |
3448-
| | CoalescePartitionsExec |
3449-
| | ProjectionExec: expr=[count(Int64(1))@1 as count(*), a@0 as a, true as __always_true] |
3450-
| | AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[count(Int64(1))] |
3451-
| | RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=1 |
3452-
| | AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[count(Int64(1))] |
3453-
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3454-
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3455-
| | |
3456-
+---------------+----------------------------------------------------------------------------------------------------------------------------+
3432+
+---------------+--------------------------------------------------------------------------------------------------------------------------+
3433+
| plan_type | plan |
3434+
+---------------+--------------------------------------------------------------------------------------------------------------------------+
3435+
| logical_plan | Projection: t1.a, t1.b |
3436+
| | Filter: CASE WHEN __scalar_sq_1.__always_true IS NULL THEN Int64(0) ELSE __scalar_sq_1.count(*) END > Int64(0) |
3437+
| | Projection: t1.a, t1.b, __scalar_sq_1.count(*), __scalar_sq_1.__always_true |
3438+
| | Left Join: t1.a = __scalar_sq_1.a |
3439+
| | TableScan: t1 projection=[a, b] |
3440+
| | SubqueryAlias: __scalar_sq_1 |
3441+
| | Projection: count(Int64(1)) AS count(*), t2.a, Boolean(true) AS __always_true |
3442+
| | Aggregate: groupBy=[[t2.a]], aggr=[[count(Int64(1))]] |
3443+
| | TableScan: t2 projection=[a] |
3444+
| physical_plan | FilterExec: CASE WHEN __always_true@3 IS NULL THEN 0 ELSE count(*)@2 END > 0, projection=[a@0, b@1] |
3445+
| | RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 |
3446+
| | HashJoinExec: mode=CollectLeft, join_type=Right, on=[(a@1, a@0)], projection=[a@3, b@4, count(*)@0, __always_true@2] |
3447+
| | CoalescePartitionsExec |
3448+
| | ProjectionExec: expr=[count(Int64(1))@1 as count(*), a@0 as a, true as __always_true] |
3449+
| | AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[count(Int64(1))] |
3450+
| | RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=1 |
3451+
| | AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[count(Int64(1))] |
3452+
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3453+
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3454+
| | |
3455+
+---------------+--------------------------------------------------------------------------------------------------------------------------+
34573456
"
34583457
);
34593458

@@ -3485,31 +3484,30 @@ async fn test_count_wildcard_on_where_scalar_subquery() -> Result<()> {
34853484
assert_snapshot!(
34863485
pretty_format_batches(&df_results).unwrap(),
34873486
@r"
3488-
+---------------+----------------------------------------------------------------------------------------------------------------------------+
3489-
| plan_type | plan |
3490-
+---------------+----------------------------------------------------------------------------------------------------------------------------+
3491-
| logical_plan | Projection: t1.a, t1.b |
3492-
| | Filter: CASE WHEN __scalar_sq_1.__always_true IS NULL THEN Int64(0) ELSE __scalar_sq_1.count(*) END > Int64(0) |
3493-
| | Projection: t1.a, t1.b, __scalar_sq_1.count(*), __scalar_sq_1.__always_true |
3494-
| | Left Join: t1.a = __scalar_sq_1.a |
3495-
| | TableScan: t1 projection=[a, b] |
3496-
| | SubqueryAlias: __scalar_sq_1 |
3497-
| | Projection: count(*), t2.a, Boolean(true) AS __always_true |
3498-
| | Aggregate: groupBy=[[t2.a]], aggr=[[count(Int64(1)) AS count(*)]] |
3499-
| | TableScan: t2 projection=[a] |
3500-
| physical_plan | FilterExec: CASE WHEN __always_true@3 IS NULL THEN 0 ELSE count(*)@2 END > 0, projection=[a@0, b@1] |
3501-
| | RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 |
3502-
| | ProjectionExec: expr=[a@2 as a, b@3 as b, count(*)@0 as count(*), __always_true@1 as __always_true] |
3503-
| | HashJoinExec: mode=CollectLeft, join_type=Right, on=[(a@1, a@0)], projection=[count(*)@0, __always_true@2, a@3, b@4] |
3504-
| | CoalescePartitionsExec |
3505-
| | ProjectionExec: expr=[count(*)@1 as count(*), a@0 as a, true as __always_true] |
3506-
| | AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[count(*)] |
3507-
| | RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=1 |
3508-
| | AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[count(*)] |
3509-
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3510-
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3511-
| | |
3512-
+---------------+----------------------------------------------------------------------------------------------------------------------------+
3487+
+---------------+--------------------------------------------------------------------------------------------------------------------------+
3488+
| plan_type | plan |
3489+
+---------------+--------------------------------------------------------------------------------------------------------------------------+
3490+
| logical_plan | Projection: t1.a, t1.b |
3491+
| | Filter: CASE WHEN __scalar_sq_1.__always_true IS NULL THEN Int64(0) ELSE __scalar_sq_1.count(*) END > Int64(0) |
3492+
| | Projection: t1.a, t1.b, __scalar_sq_1.count(*), __scalar_sq_1.__always_true |
3493+
| | Left Join: t1.a = __scalar_sq_1.a |
3494+
| | TableScan: t1 projection=[a, b] |
3495+
| | SubqueryAlias: __scalar_sq_1 |
3496+
| | Projection: count(*), t2.a, Boolean(true) AS __always_true |
3497+
| | Aggregate: groupBy=[[t2.a]], aggr=[[count(Int64(1)) AS count(*)]] |
3498+
| | TableScan: t2 projection=[a] |
3499+
| physical_plan | FilterExec: CASE WHEN __always_true@3 IS NULL THEN 0 ELSE count(*)@2 END > 0, projection=[a@0, b@1] |
3500+
| | RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1 |
3501+
| | HashJoinExec: mode=CollectLeft, join_type=Right, on=[(a@1, a@0)], projection=[a@3, b@4, count(*)@0, __always_true@2] |
3502+
| | CoalescePartitionsExec |
3503+
| | ProjectionExec: expr=[count(*)@1 as count(*), a@0 as a, true as __always_true] |
3504+
| | AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[count(*)] |
3505+
| | RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=1 |
3506+
| | AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[count(*)] |
3507+
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3508+
| | DataSourceExec: partitions=1, partition_sizes=[1] |
3509+
| | |
3510+
+---------------+--------------------------------------------------------------------------------------------------------------------------+
35133511
"
35143512
);
35153513

datafusion/core/tests/physical_optimizer/projection_pushdown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,8 +1313,8 @@ fn test_hash_join_after_projection() -> Result<()> {
13131313
assert_snapshot!(
13141314
actual,
13151315
@r"
1316-
ProjectionExec: expr=[c@2 as c_from_left, b@1 as b_from_left, a@0 as a_from_left, c@3 as c_from_right]
1317-
HashJoinExec: mode=Auto, join_type=Inner, on=[(b@1, c@2)], filter=b_left_inter@0 - 1 + a_right_inter@1 <= a_right_inter@1 + c_left_inter@2, projection=[a@0, b@1, c@2, c@7]
1316+
ProjectionExec: expr=[c@0 as c_from_left, b@1 as b_from_left, a@2 as a_from_left, c@3 as c_from_right]
1317+
HashJoinExec: mode=Auto, join_type=Inner, on=[(b@1, c@2)], filter=b_left_inter@0 - 1 + a_right_inter@1 <= a_right_inter@1 + c_left_inter@2, projection=[c@2, b@1, a@0, c@7]
13181318
DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false
13191319
DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false
13201320
"

0 commit comments

Comments
 (0)