liukun4515 commented on code in PR #3636: URL: https://github.com/apache/arrow-datafusion/pull/3636#discussion_r982961200
########## datafusion/core/tests/sql/subqueries.rs: ########## @@ -336,10 +336,10 @@ order by s_name; Projection: #part.p_partkey AS p_partkey, alias=__sq_1 Filter: #part.p_name LIKE Utf8("forest%") TableScan: part projection=[p_partkey, p_name], partial_filters=[#part.p_name LIKE Utf8("forest%")] - Projection: #lineitem.l_partkey, #lineitem.l_suppkey, Decimal128(Some(50000000000000000),38,17) * CAST(#SUM(lineitem.l_quantity) AS Decimal128(38, 17)) AS __value, alias=__sq_3 + Projection: #lineitem.l_partkey, #lineitem.l_suppkey, CAST(Float64(0.5) AS Decimal128(38, 17)) * CAST(#SUM(lineitem.l_quantity) AS Decimal128(38, 17)) AS __value, alias=__sq_3 Review Comment: It's the desired result. I think the evaluating of `cast` is done in the `SimplifyExpressions` rule, but the rule don't support the subquery now. In this pr, we move the `SimplifyExpressions` to the front of the some rule about subquery, so the optimization of `SimplifyExpressions` can't apply some expr which is in the subquery. If we want to do the evaluation `cast` for the expr in the subquery, there are two way: 1. add additional `SimplifyExpressions` in the tail of the optimizer rules 2. support subquery case for `SimplifyExpressions` rule. If we don't want the regression in this pr, I can use the method of `1` to fix it temporarily. @alamb -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org