Skip to main content

Module st_002

Module st_002 

Source
Expand description

LINT_ST_002: Unnecessary CASE statement.

SQLFluff ST02 parity: detect CASE expressions that can be replaced by simpler forms such as COALESCE(...), NOT COALESCE(...), or a plain column reference.

Detectable patterns:

  1. CASE WHEN cond THEN TRUE ELSE FALSE ENDCOALESCE(cond, FALSE)
  2. CASE WHEN cond THEN FALSE ELSE TRUE ENDNOT COALESCE(cond, FALSE)
  3. CASE WHEN x IS NULL THEN y ELSE x ENDCOALESCE(x, y)
  4. CASE WHEN x IS NOT NULL THEN x ELSE y ENDCOALESCE(x, y)
  5. CASE WHEN x IS NULL THEN NULL ELSE x ENDx
  6. CASE WHEN x IS NOT NULL THEN x ELSE NULL ENDx
  7. CASE WHEN x IS NOT NULL THEN x ENDx

Structs§

StructureSimpleCase