Find NOT IN with a subquery

Proprietary

When the subquery can return a NULL, NOT IN evaluates to unknown for every row and the outer query silently returns nothing. Many planners also fail to rewrite NOT IN as an efficient anti-join. NOT EXISTS avoids both problems. NOT IN over a literal list is not flagged.

org.openrewrite.sql.antipattern.FindNotInSubquery

Optional

markSourceBoolean

Whether to mark each occurrence in source, and apply the fix where the rule remediates. Defaults to true; set to false to leave source untouched and report only to the data table, as an analysis-only pipeline requires.

mod run . --recipe=org.openrewrite.sql.antipattern.FindNotInSubquery

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.