-
Notifications
You must be signed in to change notification settings - Fork 25.2k
QL: Add leniency option to SQL CLI #83795
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
QL: Add leniency option to SQL CLI #83795
Conversation
Pinging @elastic/es-ql (Team:QL) |
Hi @luigidellaquila, I've created a changelog YAML for you. |
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.
Looked at half of the code and, before proceeding further, I am wondering if lenient
shouldn't have been a command (to be used inside the CLI) and not a CLI option (to be used as a parameter when the CLI is started).
...ck/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/cli/SelectTestCase.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java
Outdated
Show resolved
Hide resolved
@@ -102,6 +103,11 @@ public Cli(CliTerminal cliTerminal) { | |||
.withRequiredArg() | |||
.ofType(Boolean.class) | |||
.defaultsTo(Boolean.parseBoolean(System.getProperty("cli.check", "true"))); | |||
this.lenientOption = parser.acceptsAll( |
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.
Looking at the already existent commands and options for CLI, I would have inclined to make lenient
a command and not a cli option. For example, fetch_size
is a command (FetchSizeCliCommand
class). The command can be executed multiple times during the life of the cli and an user can change the leniency with each query executed.
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.
From the session configuration point of view (and maybe consistency?), this would make indeed sense.
From a practical POV, not sure if changing this behavior on a query-by-query case would be as useful, but for those users that use the CLI integrated into other scripts, having it as an argument might be preferred.
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.
I agree, having a command would make it much more flexible, I'm implementing it now.
Do you think it makes sense to keep both (ie. the command AND the cli option) or should we just have the command?
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.
It doesn't make sense to have it in both places. We are not doing this for any setting/config so far. Please, implement it as a command only.
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.
OK, I removed the CLI option and replaced it with a command for now (lenient = true/false
).
In case we decide to go with both, re-enabling the option is straight forward.
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.
Looking better. Left few more comments.
...ck/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/cli/SelectTestCase.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java
Outdated
Show resolved
Hide resolved
private boolean debug; | ||
private boolean binary; | ||
private boolean lenient = CoreProtocol.FIELD_MULTI_VALUE_LENIENCY; |
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.
There are more and more commands and configuration settings to set. I think it's worth considering taking all these out in a separate class, like SqlConfiguration
one for example, and the CliSession to contain a reference to this configuration instance.
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.
Yes, it makes sense. Just wondering if it makes sense to have a separate PR for this.
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.
Done
.../sql/sql-client/src/test/java/org/elasticsearch/xpack/sql/client/HttpClientRequestTests.java
Outdated
Show resolved
Hide resolved
@elasticmachine update branch |
extract a class to hold the configuration
@elasticmachine update branch |
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.
LGTM
.../sql/sql-client/src/test/java/org/elasticsearch/xpack/sql/client/HttpClientRequestTests.java
Outdated
Show resolved
Hide resolved
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.
Thank you for incorporating the reviews. I've left two more comments.
.../sql/sql-client/src/test/java/org/elasticsearch/xpack/sql/client/HttpClientRequestTests.java
Outdated
Show resolved
Hide resolved
@@ -37,4 +37,14 @@ public void testSelectWithWhere() throws IOException { | |||
assertThat(readLine(), RegexMatcher.matches("\\s*2\\s*\\|\\s*test_value2\\s*")); | |||
assertEquals("", readLine()); | |||
} | |||
|
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.
I would create a test class just for this command. And, apart from the test you have below, I'd test the false
scenario as well (the one that generates an error).
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.
Done
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.
LGTM - the only comment I would make is to rename CliSession#getConfiguration to cfg or configuration() since the config object is internal and final and cannot be set.
I'm late to this PR and it seems to be CliSession == CliConfiguration at the stage (CliSession doesn't really add anything extra and it has the same scope as configuration); however in the future there might be other things to add to it so I'm fine with the refactoring.
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.
LGTM
…ijun/elasticsearch into fix-none-tsdb-index-dimension-tests * 'fix-none-tsdb-index-dimension-tests' of github.com:weizijun/elasticsearch: (37 commits) [docs] Mention JDK 17 in the Contributing docs (elastic#84018) Fix GeoIpDownloader startup during rolling upgrade (elastic#84000) Script: Fields API for Dense Vector (elastic#83550) Move InferenceConfigUpdate under VersionedNamedWriteable (elastic#84022) [ML] Fix license feature test cleanup (elastic#84020) Replace deprecated api in artifact transforms (elastic#84015) QL: Add leniency option to SQL CLI (elastic#83795) [Stack Monitoring] add kibana_stats version alias to -mb template (elastic#83930) Optimize spliterator for ImmutableOpenMap (elastic#83899) Feature usage actions for archive (elastic#83931) Use latch to speedup multi feature migration test (elastic#84007) Make action names available in NodeClient (elastic#83919) [DOCS] Re-add HTTP proxy setings from elastic#82737 (elastic#84001) Add CI matrix configuration for snapshot BWC versions (elastic#83990) Update YAML Rest tests to check for product header on all responses (elastic#83290) TSDB: Add time series aggs cancellation (elastic#83492) [DOCS] Fix percolate query headings (elastic#83988) [DOCS] Move tip for percolate query example (elastic#83972) Simplify LocalExporter cleaner function to fix failing tests (elastic#83812) [GCE Discovery] Correcly handle large zones with 500 or more instances (elastic#83785) ...
Add
lenient = true/false
command to CLI client to allow execution of lenient queries on multi-value fields.Fixes #67436