-
Notifications
You must be signed in to change notification settings - Fork 190
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
[Coral-Trino] Fix substring start index issue #499
Conversation
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.
Thank you @KevinGe00 for this PR!
coral-trino/src/main/java/com/linkedin/coral/trino/rel2trino/CoralToTrinoSqlCallConverter.java
Outdated
Show resolved
Hide resolved
coral-trino/src/test/java/com/linkedin/coral/trino/rel2trino/RelToTrinoConverterTest.java
Show resolved
Hide resolved
coral-trino/src/test/java/com/linkedin/coral/trino/rel2trino/HiveToTrinoConverterTest.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/com/linkedin/coral/common/transformers/JsonTransformSqlCallTransformer.java
Outdated
Show resolved
Hide resolved
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.
LGTM after minor style fix and integration tests
@@ -135,7 +125,7 @@ protected SqlCall transform(SqlCall sqlCall) { | |||
new GenericCoralRegistryOperatorRenameSqlCallTransformer(), | |||
|
|||
new ReturnTypeAdjustmentTransformer(configs), new UnnestOperatorTransformer(), new AsOperatorTransformer(), | |||
new JoinSqlCallTransformer(), new NullOrderingTransformer()); | |||
new JoinSqlCallTransformer(), new NullOrderingTransformer(), new SubstrIndexTransformer()); |
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.
Could you make sure every transformer is added in a new line?
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.
spotlessApply
forces this formatting
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.
Overall LGTM, thank you for the fix @KevinGe00 !
...no/src/main/java/com/linkedin/coral/trino/rel2trino/transformers/SubstrIndexTransformer.java
Outdated
Show resolved
Hide resolved
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.
LGTM
What changes are proposed in this pull request, and why are they necessary?
#434 suggested that Hive
substring
function start index is 0-based, while Trino is 1-based. Upon further investigation, we found that both Hive and Trino indexes are actually 1-based (this was the behavior before #434). The only difference is that Hive also allows 0 as a starting substring index and treats it as 1 (this was not the behavior before #434, where 0 in Hive simply mapped to 0 in Trino). #434 was reverted in #492 but the revert was released in a hot fix branch. This PR corrects the behavior to the expected semantics.To fix this, when translating from Hive to Trino, we ensure that if the hive starting substring index is 0, we change it to 1, while leaving any other index number the same. Use
CASE WHEN
if start index is another column (we don't know the actual value).How was this patch tested?
./gradlew build
updated + New unit tests
regression tests pending, Update: all regressions expected