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 12 commits into
base: master
Choose a base branch
from

Conversation

bziobrowski
Copy link
Contributor

@bziobrowski bziobrowski commented Nov 14, 2024

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.limit setting that allows for overriding it.
It only applies when limit is not set explicitly in the query and value is greater of equal 0.
By default, the new setting is set to 10 to be consistent with previous default.

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 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 63.99%. Comparing base (59551e4) to head (a49a276).
Report is 1475 commits behind head on master.

Files with missing lines Patch % Lines
...sthandler/BaseSingleStageBrokerRequestHandler.java 72.72% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14452      +/-   ##
============================================
+ Coverage     61.75%   63.99%   +2.24%     
- Complexity      207     1605    +1398     
============================================
  Files          2436     2703     +267     
  Lines        133233   148925   +15692     
  Branches      20636    22819    +2183     
============================================
+ Hits          82274    95307   +13033     
- Misses        44911    46624    +1713     
- Partials       6048     6994     +946     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 63.95% <72.72%> (+2.24%) ⬆️
java-21 63.88% <72.72%> (+2.26%) ⬆️
skip-bytebuffers-false 63.97% <72.72%> (+2.22%) ⬆️
skip-bytebuffers-true 63.86% <72.72%> (+36.13%) ⬆️
temurin 63.99% <72.72%> (+2.24%) ⬆️
unittests 63.99% <72.72%> (+2.24%) ⬆️
unittests1 56.28% <ø> (+9.39%) ⬆️
unittests2 34.44% <72.72%> (+6.71%) ⬆️

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!

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.

LGTM

@gortiz
Copy link
Contributor

gortiz commented Dec 16, 2024

Can we merge this?

public static final String CONFIG_OF_BROKER_DEFAULT_QUERY_LIMIT =
"pinot.broker.default.query.limit";

public static final int DEFAULT_BROKER_QUERY_LIMIT_OVERRIDE = Integer.MAX_VALUE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the name consistent with config key, and make it next to CONFIG_OF_BROKER_QUERY_RESPONSE_LIMIT (i.e. keep line 258 unchanged)


public static final int DEFAULT_BROKER_QUERY_LIMIT_OVERRIDE = Integer.MAX_VALUE;

// -1 means no limit; value of 10 aligns limit with PinotQuery's defaults.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think v1 allows no limit. What is the behavior when limit is not set?

@@ -140,7 +140,9 @@ public abstract class BaseSingleStageBrokerRequestHandler extends BaseBrokerRequ
protected final int _defaultHllLog2m;
protected final boolean _enableQueryLimitOverride;
protected final boolean _enableDistinctCountBitmapOverride;
protected final int _queryResponseLimit;
protected final int _queryResponseLimitOverride;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the variable name unchanged. This is not only for override, but actually the cap of the allowed limit

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

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

Choose a reason for hiding this comment

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

Will we ever hit this? In PinotQuery thrift definition, limit has a default value 10. Will limit always be set?

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.

6 participants