neilconway commented on code in PR #21240:
URL: https://github.com/apache/datafusion/pull/21240#discussion_r3016663839


##########
datafusion/sqllogictest/test_files/tpch/plans/q22.slt.part:
##########
@@ -61,40 +61,41 @@ logical_plan
 03)----Aggregate: groupBy=[[custsale.cntrycode]], aggr=[[count(Int64(1)), 
sum(custsale.c_acctbal)]]
 04)------SubqueryAlias: custsale
 05)--------Projection: substr(customer.c_phone, Int64(1), Int64(2)) AS 
cntrycode, customer.c_acctbal
-06)----------Inner Join:  Filter: CAST(customer.c_acctbal AS Decimal128(19, 
6)) > __scalar_sq_2.avg(customer.c_acctbal)
-07)------------Projection: customer.c_phone, customer.c_acctbal
-08)--------------LeftAnti Join: customer.c_custkey = 
__correlated_sq_1.o_custkey
-09)----------------Filter: substr(customer.c_phone, Int64(1), Int64(2)) IN 
([Utf8View("13"), Utf8View("31"), Utf8View("23"), Utf8View("29"), 
Utf8View("30"), Utf8View("18"), Utf8View("17")])
-10)------------------TableScan: customer projection=[c_custkey, c_phone, 
c_acctbal], partial_filters=[substr(customer.c_phone, Int64(1), Int64(2)) IN 
([Utf8View("13"), Utf8View("31"), Utf8View("23"), Utf8View("29"), 
Utf8View("30"), Utf8View("18"), Utf8View("17")]), Boolean(true)]
-11)----------------SubqueryAlias: __correlated_sq_1
-12)------------------TableScan: orders projection=[o_custkey]
-13)------------SubqueryAlias: __scalar_sq_2
-14)--------------Aggregate: groupBy=[[]], aggr=[[avg(customer.c_acctbal)]]
-15)----------------Projection: customer.c_acctbal
-16)------------------Filter: customer.c_acctbal > Decimal128(Some(0),15,2) AND 
substr(customer.c_phone, Int64(1), Int64(2)) IN ([Utf8View("13"), 
Utf8View("31"), Utf8View("23"), Utf8View("29"), Utf8View("30"), Utf8View("18"), 
Utf8View("17")])
-17)--------------------TableScan: customer projection=[c_phone, c_acctbal], 
partial_filters=[customer.c_acctbal > Decimal128(Some(0),15,2), 
substr(customer.c_phone, Int64(1), Int64(2)) IN ([Utf8View("13"), 
Utf8View("31"), Utf8View("23"), Utf8View("29"), Utf8View("30"), Utf8View("18"), 
Utf8View("17")])]
+06)----------LeftAnti Join: customer.c_custkey = __correlated_sq_1.o_custkey
+07)------------Filter: substr(customer.c_phone, Int64(1), Int64(2)) IN 
([Utf8View("13"), Utf8View("31"), Utf8View("23"), Utf8View("29"), 
Utf8View("30"), Utf8View("18"), Utf8View("17")]) AND CAST(customer.c_acctbal AS 
Decimal128(19, 6)) > (<subquery>)
+08)--------------Subquery:

Review Comment:
   The subquery appears twice in the logical plan, but there will only be one 
`ScalarSubqueryExec` in the physical plan; the subquery will be evaluated once 
and cached. I think the duplication in the logical plan arises because of how 
PushdownFilters works.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to