fix(hogql): convert a missing currency without dividing by zero - #108113
Conversation
…read $el_text on actions
|
😎 Merged successfully - details. |
🤖 CI report
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: PostHog/posthog/.coderabbit.yaml Review profile: QUIET Plan: Enterprise Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughCurrency conversion now treats a NULL source-currency rate lookup as Decimal64 zero. Element text filters accept both Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The currency and element-filter changes appear consistent with their intended behavior, and no concrete merge-blocking issue was found. Focused snapshot tests were not run in this environment. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
posthog/hogql/property.py-1553-1553 (1)
1553-1553: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAllow
$el_textin the typed element filter model.
ElementPropertyFilter.keyusesKey10, which does not include$el_text. A typed element filter with this key is rejected beforeproperty_to_exprreaches the new branch. Add$el_textto the source enum or use an action input model that permits it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: PostHog/posthog/.coderabbit.yaml
Review profile: QUIET
Plan: Enterprise
Run ID: f1391f38-7451-46ee-ab10-52393b6df6c4
📒 Files selected for processing (5)
posthog/hogql/printer/clickhouse.pyposthog/hogql/printer/test/test_printer.pyposthog/hogql/property.pyposthog/hogql/test/test_property.pyposthog/hogql/test/test_query.py
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
|
[Medium risk] Fixes currency conversion to handle missing values without errors. The PR should not merge until Apple Search Ads spend with a missing row currency is attributed to the correct account currency. Reviews (2) · Last reviewed commit: "fix(marketing-analytics): read cost rows..." |
|
A new stamphog review started for this PR — the fresh verdict replaces this approval.
A new stamphog review started for this PR — the fresh verdict replaces this approval.
|
/trunk merge |
A new stamphog review started for this PR — the fresh verdict replaces this approval.
There was a problem hiding this comment.
Approved.
This is a small, contained fix to query printing: the currency-conversion change wraps the source rate lookup in ifNull, and the element filter now treats the $el_text key like text. Tests cover both, and a teammate approved an earlier commit. The Greptile concern about a base-currency fallback applies to an approach the author reverted, and the CodeRabbit note about the typed filter enum is minor.
- Author wrote 0% of the modified lines and has 9 merged PRs in these paths (familiarity MODERATE).
- 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 10L, 3F substantive, 2311L/13F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1d-complex (2311L, 13F, two-areas, fix) |
| stamphog 2.3.0 | .stamphog/policy.yml @ ad8625b · reviewed head ad8625b |
Problem
Division by zero(Code 153) when any source row has no currency, for example an Apple Search Adslocal_spendrow without one.convertCurrencyalready guards a zero rate. A NULL currency makes the rate lookup return NULL rather than the default 0, soNULL = 0is not true and the divisor stays NULL.divideDecimalon the zero under the NULL row and throws.$el_textfails to compile withproperty_to_expr for type element not implemented for key $el_text.text, but actions saved through other paths still carry$el_text.Changes
convertCurrencywraps the source rate lookup inifNull(…, 0).$el_textnow compiles the same astext: a match againstelements_chain_texts.textdoes, not only the$el_textevent property.convertCurrency(revenue analytics, trends) change by the sameifNullwrap; CI regenerates them.How did you test this code?
convertCurrencyover a NULL and a valid source currency returns 0 and the converted value. Without the fix it fails with the sameDivision by zeroseen in production.$el_textkey.Release status
Automatic notifications
Docs update
None.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5
/writing-tests,/reviewing-with-coderabbit,/writing-pr-descriptions.$el_textnotes above came from it. Its suggested base-currency fallback was tried and reverted after review, because it misstates spend for accounts in another currency.if(rate = 0, 1, rate)still throws;ifNull(rate, 0) = 0does not.🤖 Generated with Claude Code