Dandandan commented on code in PR #15532:
URL: https://github.com/apache/datafusion/pull/15532#discussion_r2024211429


##########
datafusion/sqllogictest/test_files/explain.slt:
##########
@@ -244,6 +244,159 @@ physical_plan DataSourceExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/
 physical_plan_with_stats DataSourceExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, 
c], file_type=csv, has_header=true, statistics=[Rows=Absent, Bytes=Absent, 
[(Col[0]:),(Col[1]:),(Col[2]:)]]
 physical_plan_with_schema DataSourceExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, 
c], file_type=csv, has_header=true, schema=[a:Int32;N, b:Int32;N, c:Int32;N]
 
+# test SUM function with constant
+# Both the SUM(a + literal) and SUM(literal + a) should be optimized to SUM(a) 
+ count(*) * literal
+query TT
+EXPLAIN VERBOSE SELECT SUM(a + 1), SUM(a + 2), SUM(3 + a) FROM 
simple_explain_test

Review Comment:
   I added some thoughts of generalizing this optimization here (which should 
benefit more common uses)
   https://github.com/apache/datafusion/issues/15524#issuecomment-2771525677



-- 
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