vtlim commented on code in PR #18027: URL: https://github.com/apache/druid/pull/18027#discussion_r2167379055
########## docs/api-reference/sql-api.md: ########## @@ -229,6 +234,20 @@ Content-Length: 192 </TabItem> </Tabs> +You can also specify query-level context parameters directly within the SQL query string using the `SET` command. For more details, see [SET statements](../querying/sql.md#set-statements). + +The following request body is functionally equivalent to the previous example and uses SET instead of the `context` parameter: + +```JSON +[ Review Comment: This should be a curly brace instead of square brace ########## docs/querying/query-from-deep-storage.md: ########## @@ -131,10 +131,20 @@ The response for submitting a query includes the query ID along with basic infor "durationMs": DURATION_IN_MS, } ``` -:::info -You can't use `SET` command to set up the value `executionMode`.This context parameter must be specified using the `context` field in the Druid SQL API or Druid Web Console. -::: +Additionally, instead of specifying the `context` object within the JSON payload, you can set context parameters inline using SET statements. + +While submitting queries through the API, you can include SET statements as part of the SQL query string in the request payload: + +```bash +curl --location 'http://localhost:8888/druid/v2/sql/statements' \ +--header 'Content-Type: application/json' \ +--data '{ + "query": "SET executionMode = '\''ASYNC'\''; SET selectDestination = '\''durableStorage'\''; SELECT * FROM \"YOUR_DATASOURCE\" WHERE \"__time\" > TIMESTAMP '\''2017-09-01'\'' AND \"__time\" <= TIMESTAMP '\''2017-09-02'\''" +}' +``` + +Both methods, using SET statements or specifying context parameters in the JSON `context` object, return the same response above. Review Comment: A few thoughts: * Suggest moving it up (before "The response for..."), so it's grouped together with the request section * Since the purpose of this page is to show the ready how to query from deep storage, let's not go into so much detail on SET. A short note should suffice, such as this: ````` Note that you can also submit context parameters using [SET](link-to-doc). For example: ``` "query": "SET executionMode = '\''ASYNC'\''; SET selectDestination = '\''durableStorage'\''; SELECT * FROM \"YOUR_DATASOURCE\" WHERE \"__time\" > TIMESTAMP '\''2017-09-01'\'' AND \"__time\" <= TIMESTAMP '\''2017-09-02'\''" ``` ````` ########## docs/tutorials/tutorial-query-deep-storage.md: ########## @@ -191,6 +191,20 @@ curl --location 'http://localhost:8888/druid/v2/sql/' \ The response you get back is an empty response cause there are no records on the Historicals that match the query. +Additionally, instead of specifying the `context` object within the JSON payload, you can also set context parameters inline using SET statements. + +For example, to query pages from the `wikipedia` datasource with timestamps before `2016-06-27 00:10:00`, you can use the following API curl request: + +```bash +curl --location 'http://localhost:8888/druid/v2/sql/statements' \ +--header 'Content-Type: application/json' \ +--data '{ + "query": "SET executionMode = '\''ASYNC'\''; SELECT page FROM wikipedia WHERE __time < TIMESTAMP '\''2016-06-27 00:10:00'\'' LIMIT 10" +}' +``` + +Both methods,using SET statements orspecifying context parameters in the JSON `context` object, return the same response format. + Review Comment: Since this is a tutorial, let's just set one specific user path rather than giving them many options. My recommendation here is to update the two existing examples to use SET and remove the `context` field entirely. The point of the tutorial isn't to learn how to use the Query API (including SET/context). Someone who chooses to learn more can click the link to the reference that's already included in the "further reading" section. ########## docs/querying/using-caching.md: ########## @@ -83,8 +83,12 @@ As long as the service is set to populate the cache, you can set cache options f } } ``` + In this example the user has set `populateCache` to `false` to avoid filling the result cache with results for segments that are over a year old. For more information, see [Druid SQL client APIs](../api-reference/sql-api.md). +You can also use the SET command to specify cache options directly within your SQL query string. For more information, see [SET statements](../querying/sql.md#set-statements). + + ## Learn more Review Comment: ```suggestion You can also use the SET command to specify cache options directly within your SQL query string. For more information, see [SET statements](../querying/sql.md#set-statements). ## Learn more ``` ########## docs/api-reference/sql-ingestion-api.md: ########## @@ -101,22 +101,23 @@ The `/druid/v2/sql/task` endpoint accepts the following: ### Sample request The following example shows a query that fetches data from an external JSON source and inserts it into a table named `wikipedia`. +The example specifies two query context parameters: + +- `maxNumTasks=3`: Limits the maximum number of parallel tasks to 3. +- `finalizeAggregations=false`: Ensures Druid saving intermediate data aggregation during loading. It's useful if you want to work with intermediate data states or control aggregation later. For more information, see [Rollup](../multi-stage-query/concepts.md#rollup). Review Comment: ```suggestion - `finalizeAggregations=false`: Ensures that Druid saves the aggregation's intermediate type during ingestion. For more information, see [Rollup](../multi-stage-query/concepts.md#rollup). ``` -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
