You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2020/04/11 01:12:37 UTC
[GitHub] [drill] paul-rogers opened a new pull request #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
paul-rogers opened a new pull request #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052
# [DRILL-7603](https://issues.apache.org/jira/browse/DRILL-7603): Add schema, options to REST query
Also includes [DRILL-7604](https://issues.apache.org/jira/browse/DRILL-7604)
## Description
Update and revision of work originally done by @dobesv. All credit to @dobesv for these nice enhancements.
* DRILL-7603: Allow default schema to be set for HTTP queries, #1996
* DRILL-7604: Allow session options to be set in HTTP queries, #1997
Merges the two PRs since they touch the same files. Work stalled when a reviewer requested that the author use existing mechanisms to parse option values. Doing so was a bit tricky, and the author didn't have time. This PR does that work, which turned out to require some changes in the option mechanism. (The option mechanism has a generic set-from-Object; this PR adds a generic set-from-String.)
The revisions made it clear that the original code structure was getting a bit creaky. So, separated the REST query runner from the JSON-serializable `QueryWrapper`. The number of query options has grown to make the original constructor unwieldy, so added a `RESTQueryBuilder`.
### DRILL-7604: Allow session options to be set in HTTP queries
@dobesv's original description:
> This allows REST API requests and Web UI requests to specify a default
schema. Otherwise this is not possible for HTTP clients because the
"USE" command requires a session, which HTTP clients do not have.
> Normally session options must be set using the SET command. However,
this command does not work for HTTP clients (REST API and Web UI)
because it doesn't keep a session between requests.
### DRILL-7604: Allow session options to be set in HTTP queries
@dobesv's original description:
> This changes it so that a request can contain the options you might want
to set using the SET command. It also updates the Web UI to include a
widget to select the `store.format `option so users can specify the file
format that will be used by `CREATE TABLE AS`. Additional options could
be added later if desired without much difficulty.
> Normally session options must be set using the SET command. However,
this command does not work for HTTP clients (REST API and Web UI)
because it doesn't keep a session between requests.
## Documentation
(Adapted from @dobesv's original description.)
To submit a query:
`POST /query.json`
Parameters:
* `queryType`-- `SQL`, `PHYSICAL`, or `LOGICAL` are valid types. Use only `SQL`. Other types are for internal use only.
* `query` -- A SQL query that runs in Drill.
* `autoLimit` -- Limits the number of rows returned from the result set. (Drill 1.16+)
* `options`-- Object containing session options that you could have set using the SET command. Values may be provided as strings or typed values. A common use case would be to set `store.format`:"json" to specify that `CREATE TABLE` AS should output in JSON format. (Drill 1.18+)
* `defaultSchema` - -Specify the default schema for the request, as if the USE command was run before the query. (Drill 1.18+)
Screenshot (of original version, this PR slightly updates spacing and capitalization):

## Testing
Includes unit tests from the original PRs. Revised tests for slightly different option parsing rules. Checks both the positive and negative cases for both of the new parameters.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] arina-ielchiieva commented on issue #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
arina-ielchiieva commented on issue #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#issuecomment-612420174
@paul-rogers changes look good but I have two questions:
1. the screenshot in the PR title does not show how options will be described from WEB UI. Looks like this part of the implementation is missing. I think since we allow passing options through REST API to have ability to set them on query page.
2. When default schema was added, case when user was able to return query from Profiles was missed (see https://issues.apache.org/jira/browse/DRILL-7655). Should be this covered in your changes as well?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] arina-ielchiieva commented on a change in pull request
#2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
arina-ielchiieva commented on a change in pull request #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#discussion_r407062641
##########
File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValue.java
##########
@@ -146,6 +164,40 @@ public static OptionValue create(AccessibleScopes type, String name, Object val,
throw new IllegalArgumentException(String.format("Unsupported type %s", val.getClass()));
}
+ private static OptionValue fromString(AccessibleScopes type, String name,
+ String val, OptionScope scope, Kind kind) {
+ val = val.trim();
+ try {
+ switch (kind) {
+ case BOOLEAN: {
Review comment:
Please format case inside the switch.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] paul-rogers commented on issue #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
paul-rogers commented on issue #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#issuecomment-614176578
Rebased on master. Merged with prior commit in same area. Squashed commits. Reran all tests.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] arina-ielchiieva commented on a change in pull request
#2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
arina-ielchiieva commented on a change in pull request #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#discussion_r407062664
##########
File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValue.java
##########
@@ -146,6 +164,40 @@ public static OptionValue create(AccessibleScopes type, String name, Object val,
throw new IllegalArgumentException(String.format("Unsupported type %s", val.getClass()));
}
+ private static OptionValue fromString(AccessibleScopes type, String name,
+ String val, OptionScope scope, Kind kind) {
+ val = val.trim();
Review comment:
We don't expect value to be null? Correct?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] paul-rogers commented on a change in pull request #2052:
DRILL-7603 and DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
paul-rogers commented on a change in pull request #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#discussion_r407158975
##########
File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionValue.java
##########
@@ -146,6 +164,40 @@ public static OptionValue create(AccessibleScopes type, String name, Object val,
throw new IllegalArgumentException(String.format("Unsupported type %s", val.getClass()));
}
+ private static OptionValue fromString(AccessibleScopes type, String name,
+ String val, OptionScope scope, Kind kind) {
+ val = val.trim();
Review comment:
No, we don't. However, added an argument check to enforce non-null.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] paul-rogers commented on issue #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
paul-rogers commented on issue #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#issuecomment-612576587
@arina-ielchiieva, thanks much for the review. As far as I could tell, the only UI changes in the original PR were for the default schema. It would take a bit of effort to create a UI for a list of options. In fact, it might be better to extend the back-end to allow the user to post a series of queries in one go, with all but the last being trivial. This approach would be easier for humans because there is no need to figure out how a UI maps to a command:
```
USE foo;
ALTER SESSION SET `bar` = 'mumble';
SELECT ... FROM something ...
```
For the REST API, it is probably easier to include these extras in the REST request. A clever client can accumulate changes and include them with each query request.
The REST API can allow additional features that the UI ignores. In the case of options, the UI won't post any and the back-end will skip the options step.
What do you think?
Finally, thanks for pointing out DRILL-7655. How did that get filed if the original PR never made it into master? Anyway, I agree it should be fixed and I'll look into that for this PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] paul-rogers commented on issue #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
paul-rogers commented on issue #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#issuecomment-612655336
Updated to add the default schema to the Profiles query editor. Filed DRILL-7697 for additional improvements, such as storing the default schema in the profile so we can rerun the query without the user having to specify the schema manually.
Noticed that the two editors had drifted apart visually, so tried to unify them a bit. DRILL-7697 asks for the proper solution: a single template file included in both places.
Fixed the error you mentioned. Added a simple test program to allow testing the UI from the debugger without having to wait for a full build.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] arina-ielchiieva commented on issue #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
arina-ielchiieva commented on issue #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#issuecomment-612814487
+1, LGTM.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] arina-ielchiieva commented on issue #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
arina-ielchiieva commented on issue #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052#issuecomment-612607875
@paul-rogers sounds good. Yes, original PR did not contains Web UI functionality but I was writing there that it might be nice to have. But I am ok if we won't do right now.
Regarding DRILL-7655, original PR made into Drill actually. There were two of them and one with the schema actually got it (https://github.com/apache/drill/commit/a8c9a0f75477cb49284e337d5ebcda51318f4380).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [drill] paul-rogers merged pull request #2052: DRILL-7603 and
DRILL-7604: Add schema, options to REST query
Posted by GitBox <gi...@apache.org>.
paul-rogers merged pull request #2052: DRILL-7603 and DRILL-7604: Add schema, options to REST query
URL: https://github.com/apache/drill/pull/2052
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services