Push down IF in PostgreSQL connector#11533
Conversation
|
Since IF is lazy, it would be good to test an expression that will fail if not lazy (maybe division by zero). |
1fb872b to
cb467cf
Compare
cc @martint |
cb467cf to
fa6db8b
Compare
core/trino-main/src/main/java/io/trino/sql/planner/ConnectorExpressionTranslator.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/ConnectorExpressionTranslator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I talked with @findepi about this, we're not sure if we should translate to $if or to $case as a private case. WDYT?
There was a problem hiding this comment.
What does "a private case" mean here?
fa6db8b to
77a61ea
Compare
|
Replying to: #11533 (comment) |
core/trino-spi/src/main/java/io/trino/spi/expression/StandardFunctions.java
Outdated
Show resolved
Hide resolved
77a61ea to
e3e99dc
Compare
| @Test(dataProvider = "testConvertComparisonDataProvider") | ||
| public void testConvertIf(ComparisonExpression.Operator operator) |
There was a problem hiding this comment.
the <test-name>DataProvider is intended to be used by <test-name> test method only
why do you need it here?
just use equality
There was a problem hiding this comment.
I put it to catch future changes. I will just use equality.
| @Test | ||
| public void testIfPredicatePushdown() | ||
| { | ||
| assertThat(query("SELECT nationkey FROM nation WHERE IF(name = 'ALGERIA', true, false)")) |
There was a problem hiding this comment.
IF(condition, true, false) can be simplified by the engine to condition.
IF(name = 'ALGERIA', regionkey, nationkey) = <regionekey of Algeria>
| * $if is a function accepting 2 arguments - condition and trueValue, or 3 arguments - condition, trueValue and falseValue. | ||
| * Evaluates and returns true_value if condition is true, otherwise evaluates and returns false_value. | ||
| */ | ||
| public static final FunctionName IF_FUNCTION_NAME = new FunctionName("$if"); |
There was a problem hiding this comment.
@martint and I discussed this and the conclusion was to model IF via CASE.
see #11699 (comment) for more details.
|
Let me close and continue in #11699 as we need re-modeling. |
Description
Push down
IFin PostgreSQL connector.Relates to #11699
Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text: