jayzhan211 commented on PR #15201:
URL: https://github.com/apache/datafusion/pull/15201#issuecomment-2736677639

   @aditanase 
   
   It works too
   
   ```
   statement count 0
   create table t(a int) as values (1), (2), (3);
   
   statement count 0
   create view v as select a, count(a) from t group by a;
   
   query II rowsort
   select * from v;
   ----
   1 1
   2 1
   3 1
   
   statement count 0
   create view v2 as select "count(t.a)", a from v;
   
   query II
   select a, "count(t.a)" from v2;
   ----
   1 1
   3 1
   2 1
   
   statement ok
   create view v3 as select a, "count(t.a)" from v2;
   
   query II
   select * from v2;
   ----
   1 1
   1 2
   1 3
   
   query II
   select * from v3;
   ----
   3 1
   2 1
   1 1
   
   query TT
   explain select * from v3;
   ----
   logical_plan
   01)SubqueryAlias: v3
   02)--Projection: v2.a, v2.count(t.a)
   03)----SubqueryAlias: v2
   04)------Projection: v.count(t.a), v.a
   05)--------SubqueryAlias: v
   06)----------Aggregate: groupBy=[[t.a]], aggr=[[count(t.a)]]
   07)------------TableScan: t projection=[a]
   physical_plan
   01)AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[count(t.a)]
   02)--CoalesceBatchesExec: target_batch_size=8192
   03)----RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4
   04)------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
   05)--------AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[count(t.a)]
   06)----------DataSourceExec: partitions=1, partition_sizes=[1]
   
   query II rowsort
   select "count(t.a)", a from v;
   ----
   1 1
   1 2
   1 3
   
   statement count 0
   drop view v;
   
   statement count 0
   drop view v2;
   
   statement ok
   drop view v3;
   
   statement count 0
   drop table t;
   
   ```


-- 
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...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to