mustafasrepo commented on code in PR #9719: URL: https://github.com/apache/arrow-datafusion/pull/9719#discussion_r1538692225
########## 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 double checked this plan. It seems that expression `t.c3+t.c4` in the top projection still is a binary expression (Unfortunately from display it is not visible whether it is column or binary expression). We should have convert it to its pre-evaluated column version: `Col(t.c3+t.c4)`. If that was the case, I would expect to see following 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 ------TableScan: t projection=[c3, c4] ``` where columns `t.c3` and `t.c4` are pruned at the first projection (from bottom). Since they are no longer needed by subsequent stages. I will try to solve this problem. If I can come up with a solution I will let you know. -- 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]
