-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fixed internal error in pinot queries caused due to question mark (?) in query parameter. #73
Conversation
…n mark (?) in query parameter. Pinot PreparedStatement creates invalid query if one of the parameters has '?' in its value. Sample pinot query : `select * from table where team in (?, ?, ?)`.. Now say parameters are: 'abc', 'pqr with (?)' and 'xyz'.. Now, on executing PreparedStatement:fillStatementWithParameters method on this will return `select * from table where team in ('abc', 'pqr with ('xyz')', ?)` -- which is clearly wrong (what we wanted was `select * from table where team in ('abc', 'pqr with (?)', 'xyz')`).. The reason is the usage of replaceFirst iteration in the pinot PreparedStatement method.. Hence written a custom method to resolve the query statement rather than relying on Pinot's library method. Also raised an issue in incubator-pinot github repo: apache/pinot#6834
Codecov Report
@@ Coverage Diff @@
## main #73 +/- ##
============================================
- Coverage 81.95% 81.40% -0.56%
Complexity 377 377
============================================
Files 37 37
Lines 1452 1468 +16
Branches 148 151 +3
============================================
+ Hits 1190 1195 +5
- Misses 194 204 +10
- Partials 68 69 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
...y-service-impl/src/main/java/org/hypertrace/core/query/service/pinot/PinotClientFactory.java
Outdated
Show resolved
Hide resolved
nit: jira id can be removed from the description |
...ice-impl/src/main/java/org/hypertrace/core/query/service/pinot/PinotBasedRequestHandler.java
Outdated
Show resolved
Hide resolved
…to pinot/query/fix/question-mark
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
* Hence written this custom method to resolve the query statement rather than relying on Pinot's | ||
* library method. | ||
* This is a temporary fix and can be reverted when the Pinot issue gets resolved | ||
* Raised an issue in incubator-pinot github repo: apache/incubator-pinot#6834 |
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.
Interesting find!
...y-service-impl/src/main/java/org/hypertrace/core/query/service/pinot/PinotClientFactory.java
Show resolved
Hide resolved
...y-service-impl/src/main/java/org/hypertrace/core/query/service/pinot/PinotClientFactory.java
Outdated
Show resolved
Hide resolved
...y-service-impl/src/main/java/org/hypertrace/core/query/service/pinot/PinotClientFactory.java
Outdated
Show resolved
Hide resolved
* This is a temporary fix and can be reverted when the Pinot issue gets resolved | ||
* Raised an issue in incubator-pinot github repo: apache/incubator-pinot#6834 | ||
*/ | ||
String resolveStatement(String query, Params params) { |
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.
What happens in this method when the number of ?
don't match the number of params?
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.
if number of params are more, we drop the extras and if it's less, we replace ?
with empty string.. the loop takes care of this..
|
||
@VisibleForTesting | ||
/* | ||
* Pinot PreparedStatement creates invalid query if one of the parameters has '?' in its value. |
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.
nice documentation 💯
Pinot PreparedStatement creates invalid query if one of the parameters has '?' in its value.
Sample pinot query :
select * from table where team in (?, ?, ?)
..Now say parameters are: 'abc', 'pqr with (?)' and 'xyz'..
Now, on executing PreparedStatement:fillStatementWithParameters method on this will return
select * from table where team in ('abc', 'pqr with ('xyz')', ?)
-- which is clearly wrong
(what we wanted was
select * from table where team in ('abc', 'pqr with (?)', 'xyz')
)..The reason is the usage of replaceFirst iteration in the pinot PreparedStatement method..
Hence written a custom method to resolve the query statement rather than relying on Pinot's library method.
Also raised an issue in incubator-pinot github repo: apache/pinot#6834