Skip to content

repeat_row: Wrangle negative accumulation error messages#36229

Draft
ggevay wants to merge 1 commit intoMaterializeInc:mainfrom
ggevay:repeat_row-8-error-msgs
Draft

repeat_row: Wrangle negative accumulation error messages#36229
ggevay wants to merge 1 commit intoMaterializeInc:mainfrom
ggevay:repeat_row-8-error-msgs

Conversation

@ggevay
Copy link
Copy Markdown
Contributor

@ggevay ggevay commented Apr 23, 2026

DRAFT

Resolves SQL-165.

TODO:

  • We'll need protobuf backcompat after all, because this won't be merged into today's release.
  • ...

Replace the scattered "internal error: ..." messages raised on negative/non-positive/non-monotonic multiplicities and inconsistent accumulators with a single structured EvalError variant, MultiplicityError { kind, code_place, detail }.

The new Display does not use the "internal error:" prefix; it names the likely root cause (invalid data in a Materialize source, caused either by a bug in the external system feeding the source or by a bug in Materialize) and mentions incorrect usage of the repeat_row table function as a secondary cause.

Migrated sites:

  • src/compute/src/render/reduce.rs (DistinctBy, ReduceInaccumulable, ReduceMinsMaxes, MinsMaxesHierarchical, hierarchical mins-maxes final, ReduceMonotonic, AccumulableErrorCheck net-zero + unsigned-sum).
  • src/compute/src/render/top_k.rs (MonotonicTopK, TopK validator, MonotonicTop1).
  • src/compute/src/compute_state.rs (persist peek, index peek error trace) and compute_state/peek_result_iterator.rs (index peek ok trace), using err.to_string() to feed PeekResponse::Error.
  • src/adapter/src/coord/peek.rs and src/adapter/src/peek_client.rs constant-result fast paths: emit EvalError::MultiplicityError instead of a hand-rolled InvalidParameterValue / AdapterError::Unstructured.
  • src/storage-operators/src/s3_oneshot_sink.rs: build and stringify a MultiplicityError, mirroring the [customer-data] logging contract inline (storage-operators cannot depend on compute).
  • src/expr/src/relation/func.rs (scalar-subquery cardinality check): the old EvalError::NegativeRowsFromSubquery variant is removed.

Internal error reporting is unified: every MultiplicityError site logs through log_multiplicity_error (free function in render/errors.rs, and a thin forwarding method on ErrorLogger). All sites share the static title "invalid record multiplicity", so they merge into a single Sentry group; kind/code_place/detail go into a [customer-data]-tagged WARN breadcrumb.

Additionally fix the reduce.rs monoid-variant mismatch site: the lhs/rhs Row values no longer leak into the panic/Sentry title; a static title helps with Sentry's issue merging.

Proto backcompat is not needed for EvalError::NegativeRowsFromSubquery because it was introduced this week and hasn't shipped in any release; its proto tag (83) is reused by the new ProtoMultiplicityError.

@ggevay ggevay changed the title Unify negative-multiplicity errors into EvalError::MultiplicityError repeat_row: Wrangle negative accumulation error messages Apr 23, 2026
Replace the scattered "internal error: ..." messages raised on
negative/non-positive/non-monotonic multiplicities and inconsistent
accumulators with a single structured EvalError variant,
MultiplicityError { kind, code_place, detail }.

The new Display does not use the "internal error:" prefix; it names the
likely root cause (invalid data in a Materialize source, caused either
by a bug in the external system feeding the source or by a bug in
Materialize) and mentions incorrect usage of the repeat_row table
function as a secondary cause.

Migrated sites:

* src/compute/src/render/reduce.rs (DistinctBy, ReduceInaccumulable,
  ReduceMinsMaxes, MinsMaxesHierarchical, hierarchical mins-maxes final,
  ReduceMonotonic, AccumulableErrorCheck net-zero + unsigned-sum).
* src/compute/src/render/top_k.rs (MonotonicTopK, TopK validator,
  MonotonicTop1).
* src/compute/src/compute_state.rs (persist peek, index peek error
  trace) and compute_state/peek_result_iterator.rs (index peek ok
  trace), using err.to_string() to feed PeekResponse::Error.
* src/adapter/src/coord/peek.rs and src/adapter/src/peek_client.rs
  constant-result fast paths: emit EvalError::MultiplicityError instead
  of a hand-rolled InvalidParameterValue / AdapterError::Unstructured.
* src/storage-operators/src/s3_oneshot_sink.rs: build and stringify
  a MultiplicityError, mirroring the [customer-data] logging contract
  inline (storage-operators cannot depend on compute).
* src/expr/src/relation/func.rs (scalar-subquery cardinality check):
  the old EvalError::NegativeRowsFromSubquery variant is removed.

Internal error reporting is unified: every MultiplicityError site logs
through log_multiplicity_error (free function in render/errors.rs, and
a thin forwarding method on ErrorLogger). All sites share the static
title "invalid record multiplicity", so they merge into a single Sentry
group; kind/code_place/detail go into a [customer-data]-tagged WARN
breadcrumb.

Additionally fix the reduce.rs monoid-variant mismatch site: the lhs/rhs
Row values no longer leak into the panic/Sentry title; a static title
helps with Sentry's issue merging.

Proto backcompat is not needed for EvalError::NegativeRowsFromSubquery
because it was introduced this week and hasn't shipped in any release;
its proto tag (83) is reused by the new ProtoMultiplicityError.

Co-authored-by: Junie <junie@jetbrains.com>
@ggevay ggevay force-pushed the repeat_row-8-error-msgs branch from 8ac5c2a to 7b1c538 Compare April 23, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant