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 new setting to ignore pagination where it is unsupported in V2. #318

Merged

Conversation

Yury-Fridlyand
Copy link

@Yury-Fridlyand Yury-Fridlyand commented Aug 1, 2023

Description

Changes how pagination requests with unsupported/incompatible [with pagination] queries are handled.
Adds new setting plugins.query.ignore_unsupported_pagination:

  1. true by default
  2. when true such requests are performed without pagination
  3. when false such requests fall back to legacy engine

Misc changes:

  1. Minor logging improvements
  2. Minor doc grooming
  3. Use pagination in correctness test
curl -X PUT localhost:9200/_cluster/settings?pretty -H "Content-Type: application/json" -d '{ "transient": { "plugins.query.ignore_unsupported_pagination": true } }'

Issues Resolved

opensearch-project#1765, opensearch-project#78

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

❗ No coverage uploaded for pull request base (integ-ignore-pagination-switch@bb3c340). Click here to learn what that means.
The diff coverage is n/a.

@@                        Coverage Diff                        @@
##             integ-ignore-pagination-switch     #318   +/-   ##
=================================================================
  Coverage                                  ?   97.52%           
  Complexity                                ?     4656           
=================================================================
  Files                                     ?      408           
  Lines                                     ?    11963           
  Branches                                  ?      830           
=================================================================
  Hits                                      ?    11667           
  Misses                                    ?      289           
  Partials                                  ?        7           
Flag Coverage Δ
sql-engine 97.52% <0.00%> (?)

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

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@matthewryanwells
Copy link

Maybe update the PR description to include an example showing how you change/set the new setting. Also I noticed how the setting can be changed when making an opensearch request but how would I change the setting if I wanted to make it through the opensearchsql plugin?

@Yury-Fridlyand
Copy link
Author

Updated

@@ -41,6 +41,7 @@ public enum Key {
QUERY_SIZE_LIMIT("plugins.query.size_limit"),
ENCYRPTION_MASTER_KEY("plugins.query.datasources.encryption.masterkey"),
DATASOURCES_URI_ALLOWHOSTS("plugins.query.datasources.uri.allowhosts"),
IGNORE_UNSUPPORTED_PAGINATION("plugins.query.ignore_unsupported_pagination"),

Choose a reason for hiding this comment

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

does this only affect sql request? Maybe plugins.sql.ignore_unsupported_pagination or plugins.sql.cursor.ignore_unsupported?

Copy link
Author

Choose a reason for hiding this comment

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

It affects all pagination requests, but we support pagination in SQL only for now.
I can easily rename the setting.

Signed-off-by: Yury-Fridlyand <[email protected]>
@@ -392,7 +392,7 @@ protected static JSONObject updateClusterSettings(ClusterSetting setting, RestCl
return new JSONObject(executeRequest(request, client));
}

protected static JSONObject updateClusterSettings(ClusterSetting setting) throws IOException {
public static JSONObject updateClusterSettings(ClusterSetting setting) throws IOException {

Choose a reason for hiding this comment

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

why does this need to be made public? It's being called by ITs that extend this class.

Copy link
Author

Choose a reason for hiding this comment

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

I use it in correctness test, which does not inherit this class.

@@ -404,7 +404,7 @@ protected static JSONObject getAllClusterSettings() throws IOException {
return new JSONObject(executeRequest(request));
}

protected static class ClusterSetting {
public static class ClusterSetting {

Choose a reason for hiding this comment

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

ditto

Copy link
Author

Choose a reason for hiding this comment

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

I use it in correctness test, which does not inherit this class.

l -> l.endsWith("Request is not supported and falling back to old SQL engine")));
logSize = lines.size();

updateClusterSettings(

Choose a reason for hiding this comment

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

feels like these should be two different tests

@@ -23,6 +28,9 @@ public class SQLCorrectnessIT extends CorrectnessTestBase {
@Override
protected void init() throws Exception {
super.init();
updateClusterSettings(

Choose a reason for hiding this comment

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

is this needed? I feel like this is unnecessary for the tests to pass.

Copy link
Author

Choose a reason for hiding this comment

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

It it true by default, but previous test may set it to false.

@@ -155,8 +155,8 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
if (newSqlRequest.isExplainRequest()) {
LOG.info("Request is falling back to old SQL engine due to: " + exception.getMessage());
}
LOG.info("[{}] Request {} is not supported and falling back to old SQL engine",
QueryContext.getRequestId(), newSqlRequest);
LOG.info("[{}] Request is not supported and falling back to old SQL engine",

Choose a reason for hiding this comment

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

why?

Copy link
Author

Choose a reason for hiding this comment

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

It was dumping non anonymized query

@@ -3,7 +3,7 @@
OpenSearch SQL Reference Manual
===============================

OpenSearch SQL enables you to extract insights out of OpenSearch using the familiar SQL query syntax. Please refer to the `technical documentation <https://docs-beta.opensearch.org/>`_ for detailed information on installing and configuring opendistro-elasticsearch-sql plugin. In this user reference manual, you can find many information for your reference. In each part, we try to make it clear by adding work example along with detailed description. Here is table of contents of the documentation:
OpenSearch SQL enables you to extract insights out of OpenSearch using the familiar SQL query syntax. Please refer to the `technical documentation <https://opensearch.org/docs/latest/install-and-configure/plugins/>`_ for detailed information on installing and configuring SQL plugin. In this user reference manual, you can find many information for your reference. In each part, we try to make it clear by adding work example along with detailed description. Here is table of contents of the documentation:

Choose a reason for hiding this comment

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

❤️

@Yury-Fridlyand Yury-Fridlyand merged commit 1bb815b into integ-ignore-pagination-switch Aug 18, 2023
7 of 20 checks passed
@Yury-Fridlyand Yury-Fridlyand deleted the dev-ignore-pagination-switch branch August 18, 2023 21:57
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