-
Notifications
You must be signed in to change notification settings - Fork 94
fix(isthmus): correct strpos parameter order #676
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
Conversation
benbellick
left a comment
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.
Just two minor comments but otherwise LGTM! Thanks for doing that 🚀
| } | ||
|
|
||
| List<RexNode> operands = new ArrayList<>(call.getOperands()); | ||
| Collections.swap(operands, 0, 1); |
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.
Probably not a bad idea to put a comment here just because we have some naked numbers used to reference parameters.
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.
Is the class Javadoc not sufficient?
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.
It's probably fine, just my opinion if we wanted to make it extra clear. Feel free to ignore if you disagree.
55dd3b9 to
7b8542b
Compare
|
@benbellick I changed the comments in both PositionFunctionMapper and StringFunctionTest to (hopefully) make things clearer, along the lines of your suggestions. |
Both SQL STRPOS and POSITION functions are modelled by Calcite as Position. Parameters are substring followed by the input to be searched. This maps to the Substrait strpos function, which has the parameters of input to be searched followed by substring. The default mapping retains the argument order, which results in SQL being translated to incorrect Substrait, and correct Substrait translated to incorrect SQL. Round-trip between Substrait and SQL still works since the parameter order is reversed in both directions, resulting in the correct order again. This change adds a custom function mapper to reverse the order of the first two parameters when converting between Calcite Position and Substrait strpos functions. Signed-off-by: Mark S. Lewis <[email protected]>
7b8542b to
d6cd9db
Compare
|
@bestbeforetoday sorry, I'm not sure I am able to see those comment changes? Also, very small thing, but since we squash merge in this repo anyways, I think it is better to always do changes in new commits rather than force-pushing. This way, I can view the diff of what changed just from when I last viewed. Thanks! 🙂 |
|
I agree that adding additional commits to address review comments makes it easier to track. I accidentally amended the existing commit instead of creating a new one and was too lazy to unpick it into two separate commits since the change is small. My bad! |
Both SQL STRPOS and POSITION functions are modelled by Calcite as Position. Parameters are substring followed by the input to be searched. This maps to the Substrait strpos function, which has the parameters of input to be searched followed by substring. The default mapping retains the argument order, which results in SQL being translated to incorrect Substrait, and correct Substrait translated to incorrect SQL. Round-trip between Substrait and SQL still works since the parameter order is reversed in both directions, resulting in the correct order again.
This change adds a custom function mapper to reverse the order of the first two parameters when converting between Calcite Position and Substrait strpos functions.
Closes #662