HaoYang670 commented on code in PR #4234:
URL: https://github.com/apache/arrow-datafusion/pull/4234#discussion_r1023682648


##########
datafusion/optimizer/tests/integration-test.rs:
##########
@@ -226,6 +226,39 @@ fn concat_ws_literals() -> Result<()> {
     Ok(())
 }
 
+#[test]
+fn unfold_round() -> Result<()> {
+    let sql = "SELECT round(col_f32, col_int32) as col from test";
+    let plan = test_sql(sql)?;
+    let expected =
+        "Projection: round(CAST(test.col_f32 AS Float64) * power(Float64(10), 
CAST(CAST(test.col_int32 AS Int64) AS Float64))CAST(CAST(test.col_int32 AS 
Int64) AS Float64)CAST(test.col_int32 AS Int64)test.col_int32Float64(10) AS 
power(Float64(10),test.col_int32)) / power(Float64(10), 
CAST(CAST(test.col_int32 AS Int64) AS Float64))CAST(CAST(test.col_int32 AS 
Int64) AS Float64)CAST(test.col_int32 AS Int64)test.col_int32Float64(10) AS 
power(Float64(10),test.col_int32) AS col\
+        \n  Projection: power(Float64(10), CAST(CAST(test.col_int32 AS Int64) 
AS Float64)) AS power(Float64(10), CAST(CAST(test.col_int32 AS Int64) AS 
Float64))CAST(CAST(test.col_int32 AS Int64) AS Float64)CAST(test.col_int32 AS 
Int64)test.col_int32Float64(10), test.col_f32\
+        \n    TableScan: test projection=[col_int32, col_f32]";
+    assert_eq!(expected, format!("{:?}", plan));
+    Ok(())
+}
+
+#[test]
+fn round_partially_execute() -> Result<()> {
+    let sql = "SELECT round(col_f32, 2) as col from test";
+    let plan = test_sql(sql)?;
+    let expected =
+        "Projection: round(CAST(test.col_f32 AS Float64) * Float64(100)) / 
Float64(100) AS col\

Review Comment:
   We can benefit from the expression simplification when one of the argument 
is a constant



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

Reply via email to