You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expr: preserve operand errors in non-strict AND/OR reduce
Closes: CLU-137
Fixes two user-visible bugs in how `reduce` treats an erroring operand of
a non-strict AND/OR:
* A materialized view or query whose `mz_now()` temporal filter sits under
an OR of ANDs, e.g.
WHERE (a AND ... AND mz_now() < t) OR (b AND ... AND mz_now() < t)
could panic the compute worker (or fail to plan) with "Unsupported
temporal predicate". The shared `mz_now() < t` conjunct was left buried
inside the OR instead of being factored out, so temporal-filter
extraction failed.
* A query that should short-circuit, such as `WHERE col AND (1/0 = 1)`,
could spuriously fail at runtime (e.g. "division by zero") even on rows
where `col` is false. AND/OR are non-strict: `false AND <error>` is
`false` and `true OR <error>` is `true`, so such rows must be filtered,
not errored.
Mechanism: the generic variadic fold in `reduce` replaced a call with any
operand's literal error unconditionally, which is wrong for a function that
is not strict in errors. Fold only for the strict variadics, excluding
AND/OR and ErrorIfNull (which can absorb an operand's error at runtime).
Keeping the erroring operand then reaches `undistribute_and_or`, which
recombines operands across AND/OR's short-circuit boundary. That only
preserves error semantics for operands common to every disjunct, so skip
undistribution otherwise. A shared temporal predicate (`mz_now() < t`,
whose cast can error) is common to every disjunct, so it is still factored
out and stays extractable, unlike the reverted #37049's blunt
`could_error()` skip.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments