Repository navigation
Conversation
Interval buckets such as MULTIPLY(FLOOR(DIVIDE(col, 60000)), 60000) failed on Postgres because function operands could only be columns. Nested functions and numeric constants are now rendered inline, and a function group-by repeats the selected expression. Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #329 +/- ##
============================================
+ Coverage 81.23% 81.25% +0.01%
- Complexity 1698 1700 +2
============================================
Files 243 243
Lines 7780 7792 +12
Branches 771 773 +2
============================================
+ Hits 6320 6331 +11
+ Misses 962 961 -1
- Partials 498 500 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Can we add a Mongo/PG compatibility test for this? |
| } | ||
|
|
||
| private String getParsedExpression(final SelectTypeExpression expression) { | ||
| if (expression instanceof FunctionExpression) { |
There was a problem hiding this comment.
Any way of avoiding these instanceof checks?
There was a problem hiding this comment.
Done in 96edd60. Operands are now rendered by a PostgresFunctionOperandVisitor (inner class of PostgresFunctionExpressionVisitor), so getParsedExpression is just expression.accept(operandVisitor):
visit(FunctionExpression)renders the nested function wrapped in parenthesesvisit(ConstantExpression)inlines numeric constantsvisit(IdentifierExpression)reuses the aliased selection if present, else falls back to the data-accessor visitor- anything else falls through to the default visitor, which throws as before
The only instanceof left is value instanceof Number on the constant's value, which is a value check rather than expression-type dispatch. Unit tests and the full DocStoreQueryV1Test suite (Mongo, nested PG, flat PG) pass.
|
Can you check if we can use visitors to avoid |
…ecks Co-authored-by: Cursor <cursoragent@cursor.com>
|
Nit (Suggestion from Gemini): |
Interval buckets such as MULTIPLY(FLOOR(DIVIDE(col, 60000)), 60000) failed on Postgres because function operands could only be columns. Nested functions and numeric constants are now rendered inline, and a function group-by repeats the selected expression.