Idiomatic Materialize SQL Pattern
ANY() Equi-join condition ***If no duplicates in the unnested field*** ```mzsql WITH my_expanded_values AS (SELECT UNNEST(array|list|map) AS fieldZ FROM tableB) SELECT a.fieldA, ... FROM tableA a JOIN my_expanded_values t ON a.fieldZ = t.fieldZ ; ``` ***If duplicates exist in the unnested field*** ```mzsql WITH my_expanded_values AS (SELECT DISTINCT UNNEST(array|list|map) AS fieldZ FROM tableB) SELECT a.fieldA, ... FROM tableA a JOIN my_expanded_values t ON a.fieldZ = t.fieldZ ; ```
mz_now() cannot be used with date/time operators Rewrite the query expression; specifically, move the operation to the other side of the comparison.
mz_now() cannot be used with ORs in materialized/indexed view definitions and SUBSCRIBE statements Rewrite as UNION ALL or UNION, deduplicating as necessary:
  • In some cases, you may need to modify the conditions to deduplicate results when using UNION ALL. For example, you might add the negation of one input's condition to the other as a conjunction.
  • In some cases, using UNION instead of UNION ALL may suffice if the inputs do not contain other duplicates that need to be retained.