Flatten CASE
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
When a searched CASE expression nests another CASE
expression in its ELSE
clause, that can be flattened into the top level CASE
expression. This does not affect the simple CASE
expression.
Using Settings.transformPatternsFlattenCase
, the following transformations can be achieved:
-- With Settings.transformPatternsFlattenCase active, this: SELECT CASE WHEN a = b THEN 1 ELSE CASE WHEN c = d THEN 2 END END FROM tab; -- ... is transformed into the equivalent expression: SELECT CASE WHEN a = b THEN 1 WHEN c = d THEN 2 END FROM tab;
Feedback
Do you have any feedback about this page? We'd love to hear it!