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: [email protected] With regards, Apache Git Services
