diff options
Diffstat (limited to 'tests/fixtures/optimizer/simplify.sql')
-rw-r--r-- | tests/fixtures/optimizer/simplify.sql | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/tests/fixtures/optimizer/simplify.sql b/tests/fixtures/optimizer/simplify.sql index e54170c..c53a972 100644 --- a/tests/fixtures/optimizer/simplify.sql +++ b/tests/fixtures/optimizer/simplify.sql @@ -911,13 +911,76 @@ t1.a = 39 AND t2.b = t1.a AND t3.c = t2.b; t1.a = 39 AND t2.b = 39 AND t3.c = 39; x = 1 AND CASE WHEN x = 5 THEN FALSE ELSE TRUE END; -x = 1 AND CASE WHEN FALSE THEN FALSE ELSE TRUE END; +x = 1; x = 1 AND IF(x = 5, FALSE, TRUE); -x = 1 AND CASE WHEN FALSE THEN FALSE ELSE TRUE END; +x = 1; + +x = 1 AND CASE x WHEN 5 THEN FALSE ELSE TRUE END; +x = 1; x = y AND CASE WHEN x = 5 THEN FALSE ELSE TRUE END; x = y AND CASE WHEN x = 5 THEN FALSE ELSE TRUE END; x = 1 AND CASE WHEN y = 5 THEN x = z END; x = 1 AND CASE WHEN y = 5 THEN 1 = z END; + +-------------------------------------- +-- Simplify Conditionals +-------------------------------------- +IF(TRUE, x, y); +x; + +IF(FALSE, x, y); +y; + +IF(FALSE, x); +NULL; + +IF(NULL, x, y); +y; + +IF(cond, x, y); +CASE WHEN cond THEN x ELSE y END; + +CASE WHEN TRUE THEN x ELSE y END; +x; + +CASE WHEN FALSE THEN x ELSE y END; +y; + +CASE WHEN FALSE THEN x WHEN FALSE THEN y WHEN TRUE THEN z END; +z; + +CASE NULL WHEN NULL THEN x ELSE y END; +y; + +CASE 4 WHEN 1 THEN x WHEN 2 THEN y WHEN 3 THEN z ELSE w END; +w; + +CASE 4 WHEN 1 THEN x WHEN 2 THEN y WHEN 3 THEN z WHEN 4 THEN w END; +w; + +CASE WHEN value = 1 THEN x ELSE y END; +CASE WHEN value = 1 THEN x ELSE y END; + +CASE WHEN FALSE THEN x END; +NULL; + +CASE 1 WHEN 1 + 1 THEN x END; +NULL; + +CASE WHEN cond THEN x ELSE y END; +CASE WHEN cond THEN x ELSE y END; + +CASE WHEN cond THEN x END; +CASE WHEN cond THEN x END; + +CASE x WHEN y THEN z ELSE w END; +CASE WHEN x = y THEN z ELSE w END; + +CASE x WHEN y THEN z END; +CASE WHEN x = y THEN z END; + +CASE x1 + x2 WHEN x3 THEN x4 WHEN x5 + x6 THEN x7 ELSE x8 END; +CASE WHEN (x1 + x2) = x3 THEN x4 WHEN (x1 + x2) = (x5 + x6) THEN x7 ELSE x8 END; |