eejbyfeldt commented on code in PR #13032:
URL: https://github.com/apache/datafusion/pull/13032#discussion_r1809298618
##########
datafusion/sqllogictest/test_files/cse.slt:
##########
@@ -199,19 +199,19 @@ physical_plan
# Surely only once but also conditionally evaluated subexpressions
query TT
EXPLAIN SELECT
- (a = 1 OR random() = 0) AND (a = 1 OR random() = 1) AS c1,
- (a = 2 AND random() = 0) OR (a = 2 AND random() = 1) AS c2,
+ (a = 1 OR random() = 0) AND (a = 2 OR random() = 1) AS c1,
+ (a = 1 AND random() = 0) OR (a = 2 AND random() = 1) AS c2,
CASE WHEN a + 3 = 0 THEN a + 3 + random() ELSE 0 END AS c3,
CASE WHEN a + 4 = 0 THEN 0 ELSE a + 4 + random() END AS c4
FROM t1
----
logical_plan
-01)Projection: (__common_expr_1 OR random() = Float64(0)) AND (__common_expr_1
OR random() = Float64(1)) AS c1, __common_expr_2 AND random() = Float64(0) OR
__common_expr_2 AND random() = Float64(1) AS c2, CASE WHEN __common_expr_3 =
Float64(0) THEN __common_expr_3 + random() ELSE Float64(0) END AS c3, CASE WHEN
__common_expr_4 = Float64(0) THEN Float64(0) ELSE __common_expr_4 + random()
END AS c4
-02)--Projection: t1.a = Float64(1) AS __common_expr_1, t1.a = Float64(2) AS
__common_expr_2, t1.a + Float64(3) AS __common_expr_3, t1.a + Float64(4) AS
__common_expr_4
+01)Projection: (__common_expr_1 OR random() = Float64(0)) AND (t1.a =
Float64(2) OR random() = Float64(1)) AS c1, __common_expr_1 AND random() =
Float64(0) OR t1.a = Float64(2) AND random() = Float64(1) AS c2, CASE WHEN
__common_expr_2 = Float64(0) THEN __common_expr_2 + random() ELSE Float64(0)
END AS c3, CASE WHEN __common_expr_3 = Float64(0) THEN Float64(0) ELSE
__common_expr_3 + random() END AS c4
+02)--Projection: t1.a = Float64(1) AS __common_expr_1, t1.a + Float64(3) AS
__common_expr_2, t1.a + Float64(4) AS __common_expr_3, t1.a
Review Comment:
This was due to me modifying this query to avoid it being rewritten by this
patch. But when I did it I was unaware about the logic around conditionals in
CSE. I changed the modification slightly and we are no longer missing any cse.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]