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

Add broker setting to override default implicit query response limit #14452

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

bziobrowski
Copy link
Contributor

By default single stage query engine (aka v1) uses implicit limit of 10 rows when no limit is set.
This PR adds pinot.broker.default.query.response.limit that allows for overriding it.
It only applies when limit is not set explicitly in the query.
By default, the new setting is disabled (via value being lower than 0).

Copy link
Collaborator

@vrajat vrajat left a comment

Choose a reason for hiding this comment

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

A reasonable chunk of the diff is because of rename of:

  • _queryResponseLimit -> _queryResponseLimitOverride
  • DEFAULT_BROKER_QUERY_RESPONSE_LIMIT -> DEFAULT_BROKER_QUERY_RESPONSE_LIMIT_OVERRIDE

The logic is the same though ?

Also the semantics of DEFAULT_BROKER_QUERY_RESPONSE_LIMIT has been changed.

Am I interpreting the diff correctly ?

@bziobrowski
Copy link
Contributor Author

I renamed the variables (but not setting keys) because, in my opinion, existing query response limit is badly named. It is not a default but rather an override because it applies even when sql command contains limit clause (and only applies conditionally ).
The new setting only applies when limit is not set.

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.79%. Comparing base (59551e4) to head (460be0a).
Report is 1343 commits behind head on master.

Files with missing lines Patch % Lines
...sthandler/BaseSingleStageBrokerRequestHandler.java 63.63% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14452      +/-   ##
============================================
+ Coverage     61.75%   63.79%   +2.04%     
- Complexity      207     1565    +1358     
============================================
  Files          2436     2663     +227     
  Lines        133233   146219   +12986     
  Branches      20636    22404    +1768     
============================================
+ Hits          82274    93282   +11008     
- Misses        44911    46040    +1129     
- Partials       6048     6897     +849     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 63.76% <63.63%> (+2.05%) ⬆️
java-21 63.67% <63.63%> (+2.05%) ⬆️
skip-bytebuffers-false 63.78% <63.63%> (+2.03%) ⬆️
skip-bytebuffers-true 63.66% <63.63%> (+35.93%) ⬆️
temurin 63.79% <63.63%> (+2.04%) ⬆️
unittests 63.79% <63.63%> (+2.04%) ⬆️
unittests1 55.53% <ø> (+8.64%) ⬆️
unittests2 34.12% <63.63%> (+6.39%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@vrajat vrajat left a comment

Choose a reason for hiding this comment

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

I think I understand the change now. Repeating to verify:

Current Behavior:

If pinot.broker.enable.query.limit.override is set AND PinotQuery.limit > pinot.broker.enable.query.limit, then override the limit.

PR behavior

If pinot.broker.default.query.response.limit is set AND no limit in query, then set limit.
Override logic continues to apply.

A couple of things that threw me off course are:

  • Rename to OVERRIDE.
  • New config param name has default in it and rest is the same. I assumed it had something to do with default override limit.

@bziobrowski
Copy link
Contributor Author

Current formula is :
if pinot.broker.enable.query.limit.override and PinotQuery.limit > pinot.broker.query.response.limit then use pinot.broker.query.response.limit`
so it's basically an upper bound on allowed limit value.
PR behavior is as you wrote above.

@vrajat
Copy link
Collaborator

vrajat commented Nov 15, 2024

PR behavior is as you wrote above.

Got it. And the test cases test the new functionality only.

Copy link
Collaborator

@yashmayya yashmayya left a comment

Choose a reason for hiding this comment

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

Thanks for the patch @bziobrowski!

@@ -308,6 +313,10 @@ protected BrokerResponse handleRequest(long requestId, String query, SqlNodeAndO
}
}

if (isDefaultQueryResponseLimitEnabled() && !pinotQuery.isSetLimit()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we instead keep the default value for pinot.broker.default.query.response.limit as 10 and avoid this "enabled" check? Basically we'd then simply set the query limit to whatever the value of the config is (when there's no explicit limit set in the query).

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 - I was just about commenting the same thing in the CommonConstants file. That will also make documentation of this feature simpler. No need to explain when this limit is enabled

Copy link
Collaborator

Choose a reason for hiding this comment

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

That will also make documentation of this feature simpler. No need to explain when this limit is enabled

There's no new config for that here anyway though, the enabled check was simply verifying whether the config value was > -1. The enabled config is for the existing "override" limit config.

Copy link
Collaborator

@vrajat vrajat Nov 22, 2024

Choose a reason for hiding this comment

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

IIUC, the new behaviour will be:
If query does not have a limit clause:

  • Limit will be 10.
  • If a config parameter with default in its name is set, then the limit will be set to config value

Finally, limit will be overriden by a config param with override in its name.

My suggestion is to remove Limit will be 10 statement

Copy link
Collaborator

@yashmayya yashmayya Nov 22, 2024

Choose a reason for hiding this comment

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

That's not backward compatible though, the v1 engine has always had a default limit of 10 for queries with no explicit limit set and we can't really safely change that.

Nvm, I think I misunderstood you and you're actually proposing the same thing as me.

Comment on lines +257 to +258
public static final String CONFIG_OF_BROKER_DEFAULT_QUERY_RESPONSE_LIMIT =
"pinot.broker.default.query.response.limit";
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about naming this pinot.broker.default.query.limit instead? I know that this isn't exactly aligned with the other config name but I agree with you in that it seems poorly named (both the "response" aspect and the fact that it doesn't state that it's an override) and it's fine if we don't stick to the same pattern.


// this test uses separate cluster because it needs to change broker configuration
// which is only done once per suite
public class BrokerQueryLimitTest extends BaseClusterIntegrationTest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need an entire integration test suite for this? Seems a little heavyweight especially considering Pinot's integration tests have a fairly significant setup time / cost associated with them. We might be okay with simple unit tests for this instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For my information, is there a way to test SSQE queries as unit tests ? I know MSQE queries can be tested using QueryEnvironment

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't go through the broker request handler however.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I just realized that the broker request handler classes don't have a good setup for unit tests and it might be a fair amount of refactoring work to make it properly testable 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the reason I used integration test is because broker isn't triggered in unit tests .

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.

4 participants