Dandandan commented on code in PR #13032:
URL: https://github.com/apache/datafusion/pull/13032#discussion_r1808852820
##########
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
03)----TableScan: t1 projection=[a]
physical_plan
-01)ProjectionExec: expr=[(__common_expr_1@0 OR random() = 0) AND
(__common_expr_1@0 OR random() = 1) as c1, __common_expr_2@1 AND random() = 0
OR __common_expr_2@1 AND random() = 1 as c2, CASE WHEN __common_expr_3@2 = 0
THEN __common_expr_3@2 + random() ELSE 0 END as c3, CASE WHEN __common_expr_4@3
= 0 THEN 0 ELSE __common_expr_4@3 + random() END as c4]
-02)--ProjectionExec: expr=[a@0 = 1 as __common_expr_1, a@0 = 2 as
__common_expr_2, a@0 + 3 as __common_expr_3, a@0 + 4 as __common_expr_4]
+01)ProjectionExec: expr=[(__common_expr_1@0 OR random() = 0) AND (a@3 = 2 OR
random() = 1) as c1, __common_expr_1@0 AND random() = 0 OR a@3 = 2 AND random()
= 1 as c2, CASE WHEN __common_expr_2@1 = 0 THEN __common_expr_2@1 + random()
ELSE 0 END as c3, CASE WHEN __common_expr_3@2 = 0 THEN 0 ELSE __common_expr_3@2
+ random() END as c4]
+02)--ProjectionExec: expr=[a@0 = 1 as __common_expr_1, a@0 + 3 as
__common_expr_2, a@0 + 4 as __common_expr_3, a@0 as a]
Review Comment:
Here it loses the `a@0= 2` 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]