mustafasrepo commented on code in PR #9719: URL: https://github.com/apache/arrow-datafusion/pull/9719#discussion_r1542495995
########## datafusion/sqllogictest/test_files/project_complex_sub_query.slt: ########## @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +########## +## Prepare Statement Tests +########## + +statement ok +CREATE EXTERNAL TABLE t ( +c1 INT NOT NULL, +c2 INT NOT NULL, +c3 INT NOT NULL, +c4 INT NOT NULL, +c5 INT NOT NULL +) +STORED AS CSV +WITH HEADER ROW +LOCATION '../core/tests/data/demo.csv'; + +query TT +explain SELECT c3+c4, SUM(c3+c4) OVER() +FROM t; +---- +logical_plan +Projection: t.c3 + t.c4, SUM(t.c3 + t.c4) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING +--WindowAggr: windowExpr=[[SUM(CAST(t.c3 + t.c4 AS Int64)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] +----Projection: t.c3 + t.c4 AS t.c3 + t.c4, t.c3, t.c4 +------TableScan: t projection=[c3, c4] Review Comment: I think same problem still occurs in the `LogicalPlan::Window` where inner expression of the `Cast` is binary expression. I would expect `Projection` immediately top of the `TableScan` to only include expression: `t.c3 + t.c4 AS t.c3 + t.c4` because. Subsequent stages doesn't refer `t.c3` or `t.c4`. If you rewrite the expression for window also (as in projection). We should get that plan. In short we have to rewrite expressions that contribute to common expression count during `f_down` pass. -- 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]
