feat(eap): Add NULL-safe division and ConditionalFormula support for formulas #7697
+1,070
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds two features to support complex formula calculations in EAP queries:
1. NULL-safe division
When a
BinaryFormulawithOP_DIVIDEhas adefault_valuespecified, the division now safely handles NULL and zero divisors:This enables calculations like
count / hours_since_first_seenwherehours_since_first_seenderives frommin(timestamp).2. ConditionalFormula support (waiting for sentry-protos PR #173)
Adds support for
Column.ConditionalFormulato express conditional expressions:The code is implemented and ready but dormant until the proto is released. Uses
_has_proto_field()helper to safely check for proto fields that don't exist yet.Changes
resolver_trace_item_table.py:_has_proto_field()helper for safe proto field checkingCOMPARISON_OP_TO_EXPRmapping for conditional formula operators_formula_to_expression()for NULL-safe division_conditional_formula_to_expression()using existingif_cond()DSL_column_to_expression()to handleconditional_formula_get_reliability_context_columns()for conditional formulasproto_visitor.py:ColumnWrapper.accept()to traverse conditional formula childrenTest plan
test_hourly_rate_with_dynamic_divisor_using_aggregatepasses (NULL-safe division)test_conditional_rate_based_on_aggregate_first_seenskips until proto available🤖 Generated with Claude Code