-
Notifications
You must be signed in to change notification settings - Fork 270
fix(db): support numeric properties in chart aggregations #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…implify where conditions
|
@hrsong99 is attempting to deploy a commit to the Coderax's projects Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughUpdated aggregation property handling in the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/db/src/services/chart.service.ts (1)
176-177: Numeric property aggregations now correctly avoidnotEmpty()on numericsThe switch to
toFloat64OrNull(${getSelectPropertyKey(event.property)})in all four aggregation branches plus droppingnotEmpty()from the WHERE clause is aligned with ClickHouse patterns and should resolve theIllegal type UInt64 of argument of function notEmptyerror while safely handling string/empty values.One small optional tweak you might consider: instead of (or in addition to)
sb.where.property = \${getSelectPropertyKey(event.property)} IS NOT NULL`, predicate on the converted expression, e.g.toFloat64OrNull() IS NOT NULL`, or even omit this extra WHERE since the aggregate already ignores NULLs. That would make it explicit that only successfully castable values are counted, regardless of the underlying column type or map default behavior.Also applies to: 181-182, 186-187, 191-192
|
Thanks! Looks like you have a conflict after we added revenue tracking. Could you resolve it and I'll merge this |
|
Done! |
|
Okey, so I just tried this, and it still fails.
In this commit 56b01ca I have added |
|
Sorry about that, I'm currently unable to test the code so it was something I thought might work. I've tried modifying the code to use |

When creating a Dashboard, there's an issue where aggregating numeric properties (like
duration) would crash ClickHouse withIllegal type UInt64 of argument of function notEmpty.The query builder is applying
notEmpty()to all properties to filter out empty strings, but I believe this function throws an error when applied to numeric columns.Changes:
notEmpty()check from the where clause.toFloat64for toFloat64OrNull.This should allow numeric columns to pass through correctly while still safely handling empty strings (returning
null, which aggregation functions ignore).Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.