Fix translate doesn't work on CHAR values#14478
Fix translate doesn't work on CHAR values#14478albericgenius wants to merge 2 commits intotrinodb:masterfrom
Conversation
core/trino-parser/src/main/java/io/trino/sql/tree/CharLiteral.java
Outdated
Show resolved
Hide resolved
2f71209 to
c86d9d6
Compare
|
@findepi if we need to replace the deprecated assertFunction by |
@martint might be the best person to speak to this |
c86d9d6 to
9c665c2
Compare
|
commit to fix the CI issue. |
|
@albericgenius, there's no issue for it, but feel free to do it if you want and have time. There are dozens of classes that still rely on the deprecated assertFunction and any help to migrate those is appreciated. Take a look at #14528 for some examples. |
9c665c2 to
7beddb8
Compare
@martint I have a look at #14528, Thanks for sharing.I have time and interested in Trino, but sometime i do not know where I could start. please feel free to assign the task to me. @findepi I have rebased the lasted code, but there is still one Product test failed because of "Test execution exceeded timeout of 2.00h". Which is not relative to my commit(I think :) ). I just added a translate function for char. I have changed to use assertFunction in the test, when we migrate to new assertions, i will do it later. |
There was a problem hiding this comment.
add cases with trailing spaces in the result
assertFunction("translate(CHAR 'abc', 'c', ' ')", VARCHAR, "ab ");
assertFunction("translate(CHAR 'abc ', 'c', 'z')", VARCHAR, "abz ");
There was a problem hiding this comment.
Also, add tests where the translation strings contain more than one character.
|
Code looks generally OK, but per #14038 (comment) i think the proper fix would be to do #9031. |
37b2781 to
2ffd87d
Compare
@findepi i agree with you, and I have tried to fix via char/varchar coercion in the beginning. But seems it affected a lot of functions, so i go this way to follow the same logic as charSubstring, castCharToCodePoints and concat. For my opinion, at least it make sense for There are 47 checks cancelled, I will rebase to fix this. Make pr ready to merge first. :) |
2ffd87d to
9020754
Compare
yes, this is not easy |
Hi @findepi But for typeCoercion.getCommonSuperType, I do not know how to fit all requirement(all existed functions). So i probably track on #9031 and learn how to address this issue. For current commit, add translateChar, for my side, it is good to merge, because for the case of |
|
@martint sorry to bother again, I think this fix is good for |
martint
left a comment
There was a problem hiding this comment.
This is an ok workaround until the underlying issue is fixed.
core/trino-main/src/main/java/io/trino/operator/scalar/StringFunctions.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/operator/scalar/StringFunctions.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Also, add tests where the translation strings contain more than one character.
9020754 to
23e7d7f
Compare
|
@martint :) , I addressed the code style issues, Thanks for share this for me, if there any other issue, I will update as soon as possible. |
|
Sorry for the late reply. Can you please add a few tests with various combinations of CHAR and VARCHAR? The existing tests only cover all values being of the same type or only one value being CHAR. For instance, we should test |
Just curious, by testing do you mean Trino wants to support those permutations as well or those tests should be added to ensure other permutations are not supported? I understand the rational that input should be the same type as output, however the public document describe the inputs to be |
|
👋 @albericgenius @findepi @martint - this PR has become inactive. We hope you are still interested in working on it. Please let us know, and we can try to get reviewers to help with that. We're working on closing out old and inactive PRs, so if you're too busy or this has too many merge conflicts to be worth picking back up, we'll be making another pass to close it out in a few weeks. |
|
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
|
@martint and @findepi .. how do you want to proceed here with @albericgenius |
|
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
|
Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time. |
Description
Fix #14038
Fix translate doesn't work on CHAR values
This PR is used to proposal the solution, there are some test cases not passed.
if the direction is correct, I will fix the test cases asap.
Non-technical explanation
Release notes
(x) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: