Skip to content
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

Merged
merged 5 commits into from
Apr 25, 2021

Conversation

singhalprerana
Copy link
Contributor

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

…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
@singhalprerana singhalprerana requested review from avinashkolluru and a team April 23, 2021 10:07
@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #73 (d161575) into main (b67c30d) will decrease coverage by 0.55%.
The diff coverage is 85.00%.

Impacted file tree graph

@@             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     
Flag Coverage Δ Complexity Δ
integration 81.40% <85.00%> (-0.56%) 14.00 <0.00> (ø)
unit 78.96% <85.00%> (-0.55%) 363.00 <0.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...e/core/query/service/pinot/PinotClientFactory.java 66.66% <85.00%> (-12.88%) 3.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b67c30d...d161575. Read the comment docs.

@github-actions

This comment has been minimized.

@findingrish
Copy link

nit: jira id can be removed from the description

@singhalprerana singhalprerana changed the title ENG-8858: Fixed internal error in pinot queries caused due to question mark (?) in query parameter. Fixed internal error in pinot queries caused due to question mark (?) in query parameter. Apr 23, 2021
@github-actions

This comment has been minimized.

@github-actions

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting find!

* 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) {

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?

Copy link
Contributor Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice documentation 💯

@singhalprerana singhalprerana requested a review from a team April 24, 2021 04:09
@github-actions

This comment has been minimized.

@singhalprerana singhalprerana merged commit 1a80901 into main Apr 25, 2021
@singhalprerana singhalprerana deleted the pinot/query/fix/question-mark branch April 25, 2021 08:03
@github-actions
Copy link

Unit Test Results

  22 files  ±0    22 suites  ±0   7s ⏱️ ±0s
111 tests +1  111 ✔️ +1  0 💤 ±0  0 ❌ ±0 

Results for commit 1a80901. ± Comparison against base commit b67c30d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants