[CALCITE-7624] Support BigDecimal for FETCH and OFFSET in Enumerable#5050
[CALCITE-7624] Support BigDecimal for FETCH and OFFSET in Enumerable#5050tkalkirill wants to merge 4 commits into
Conversation
|
@xiedeyantu Can you take a look?
Of course, I could create a task for each question and resolve them there. Is that standard practice, or should I address them via the dev list first? |
|
In general we should push as much as possible in the validation and code generation layers. |
|
@tkalkirill Thanks for spinning this feature out into a separate piece of work! For the first point, I agree with Mihai’s suggestion—we should intercept invalid formats as early as possible in the pre-processing logic, and we can also refer to how errors are gracefully handled in the existing execution flow. This would also serve as good groundwork for your earlier PR. For the second point, I think we should add something similar to what you implemented in your previous PR. I’m wondering whether we should deprecate the old approach and support only BigDecimal going forward? This might be worth continuing to discuss in the Jira ticket. On the third point, I also agree with Mihai. We could consider following PostgreSQL’s behavior, since Calcite often takes Postgres as a reference first; if Postgres doesn’t support something, then other mainstream implementations are considered. That said, if you believe another approach is more reasonable, as long as we document the rationale clearly where needed, that should be acceptable. For the fourth point, I do think it makes sense to allow updates. Regarding the fifth point, I personally feel we should unify the behavior—widening the type shouldn’t break compatibility. On the sixth point, for adapters, I think we could either apply different validation logic per backend or let each backend handle its own checks. Both options seem reasonable to me; let’s see if others have better ideas. If not, as long as we provide accurate documentation, that should be fine. |
|
|
@xiedeyantu I’ve tried to make the requested changes on all points. We are continuing to discuss the second point in the ticket. |
| result.format); | ||
|
|
||
| Expression v = builder.append("child", result.block); | ||
| Expression roundingPolicyExp = getRoundingPolicy(implementor); |
There was a problem hiding this comment.
I don't think we need such a complex strategy; we can control the rounding method using expressions instead. We simply need to select a standard approach and document it with a comment. I suspect @mihaibudiu would also prefer a simpler implementation.
There was a problem hiding this comment.
With this approach, users can quite easily override this behavior.
For instance, someone might need it to work like it does in Oracle.
If that can also be achieved using expressions, please let me know how.
There was a problem hiding this comment.
Didn't your previous PR add support for expressions(like limit round(?))? My point is that we can support various types of logic using any syntax we choose; if you want to include this feature, I certainly wouldn't object. We could also get Mihai's opinion on this.
There was a problem hiding this comment.
Every flag like this increases the space of configurations to test. I would keep this one simple by hardwiring the rounding policy.
There was a problem hiding this comment.
@xiedeyantu And how can we override the expression later if necessary?
@mihaibudiu I propose to leave the option to override the rounding policy.
There was a problem hiding this comment.
What I really meant was that if we could support expressions in limit and offset, we could do a lot of things, even support partial rounding logic, thus eliminating the need for additional configuration options. As for specific implementation details, I haven't considered that in detail yet.



Jira Link
CALCITE-7624
Changes Proposed
This PR proposes using BigDecimal for FETCH and OFFSET, so that the following SQL queries work: