BETWEEN connector expression translation#11684
Conversation
965d1b6 to
31a437e
Compare
There was a problem hiding this comment.
Do we need a new function?
I would prefer to model this as $and(x >= y, x <= z).
BETWEEN has important property that it evaluates the LHS value once, but that doesn't matter for deterministic predicates, and we don't want to handle non-deterministic predicates in connector expressions.
(That's also why we could model boolean AND as an ordinary function. Lazy-evaluation (or lack thereof) isn't defined for connector expressions.)
There was a problem hiding this comment.
After writing this PR, I've noticed that BETWEEN is already modeled the way you said at DomainTranslator, so the implementation will only be reflected in the projection pushdown. Do you think I should implement the conversion to an $and right now or just wait with this PR?
There was a problem hiding this comment.
What for would you want to wait for here?
There was a problem hiding this comment.
I thought I might need to wait for a connector that will actually use this, but seems like we're ok with just adding this (with tests) so I'll continue
There was a problem hiding this comment.
PostgreSQL would use this already, so you can try add tests there.
see io.trino.plugin.postgresql.TestPostgreSqlConnectorTest#test*PredicatePushdown
There was a problem hiding this comment.
GREATER_THAN_OR_EQUAL and LESS_THAN_OR_EQUAL are currently not supported in PostgreSQL:
There was a problem hiding this comment.
i guess we should just add them there?
There was a problem hiding this comment.
Since:
connectorExpressionRewriteris created at the constructor.RewriteComparisonis part ofio.trino.plugin.jdbc.expressionand not ofio.trino.plugin.postgresql.- My understanding of this:
I think that my best option is to add a subclass to RewriteComparison at io.trino.plugin.postgresql and return Optional.empty() on rewrite if the operator is one of these and io.trino.plugin.postgresql#isEnableStringPushdownWithCollate(context.getSession()) == false. Maybe I can also check if the operands are of String type (how do you think I should do that?).
Another option is to create two connectorExpressionRewriters (with these operators and without) and dynamically choose between the two according to the result of isEnableStringPushdownWithCollate.
WDYT?
There was a problem hiding this comment.
cc @hashhar on the above
in any case, let's split the engine part (handling of BETWEEN)
and PostgreSQL part (handling of inequalities) into separate PRs.
thanks
31a437e to
d39d4b3
Compare
ca8a655 to
d39d4b3
Compare
|
CI #11016 |
Translate BETWEEN predicate to connector expression and rewrite it in PostgreSQL connector