vtlim commented on code in PR #18179:
URL: https://github.com/apache/druid/pull/18179#discussion_r2223980180


##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:

Review Comment:
   ```suggestion
   4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example, you can insert the 
following context parameters:
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.

Review Comment:
   lowercase W in web



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.

Review Comment:
   ```suggestion
      The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors.
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."

Review Comment:
   ```suggestion
     "Learn how to configure the query context
     to customize query execution behavior and optimize performance."
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.

Review Comment:
   Reorder sentences 2 and 3:
   ```suggestion
   You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md).
   This approach is useful when integrating Druid with BI tools or Java 
applications.
   When connecting to Druid through JDBC, you set query context parameters a 
JDBC connection properties object.
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.

Review Comment:
   ```suggestion
   1. **Click** the **Engine** selector next to the **Run** button to choose 
the appropriate query type. In most cases, you can leave the engine as `Auto` 
to let Druid choose the best engine for you.
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).

Review Comment:
   "within your query or through the web console"



##########
docs/querying/query-context-reference.md:
##########
@@ -126,3 +132,10 @@ vectorization. These query types will ignore the 
`vectorize` parameter even if i
 |`vectorize`|`true`|Enables or disables vectorized query execution. Possible 
values are `false` (disabled), `true` (enabled if possible, disabled otherwise, 
on a per-segment basis), and `force` (enabled, and groupBy or timeseries 
queries that cannot be vectorized will fail). The `"force"` setting is meant to 
aid in testing, and is not generally useful in production (since real-time 
segments can never be processed with vectorized execution, any queries on 
real-time data will fail). This will override 
`druid.query.default.context.vectorize` if it's set.|
 |`vectorSize`|`512`|Sets the row batching size for a particular query. This 
will override `druid.query.default.context.vectorSize` if it's set.|
 |`vectorizeVirtualColumns`|`true`|Enables or disables vectorized query 
processing of queries with virtual columns, layered on top of `vectorize` 
(`vectorize` must also be set to true for a query to utilize vectorization). 
Possible values are `false` (disabled), `true` (enabled if possible, disabled 
otherwise, on a per-segment basis), and `force` (enabled, and groupBy or 
timeseries queries with virtual columns that cannot be vectorized will fail). 
The `"force"` setting is meant to aid in testing, and is not generally useful 
in production. This will override 
`druid.query.default.context.vectorizeVirtualColumns` if it's set.|
+
+## Learn more
+

Review Comment:
   ```suggestion
   
   For more information, see the following topics:
   
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:

Review Comment:
   ```suggestion
   The following example shows a native query that sets the query ID to 
`only_query_id_test`:
   ```



##########
docs/querying/querying.md:
##########
@@ -152,3 +152,6 @@ Possible Druid error codes for the `error` field include:
 |`Query cancelled`|500|The query was cancelled through the query cancellation 
API.|
 |`Truncated response context`|500|An intermediate response context for the 
query exceeded the built-in limit of 7KiB.<br/><br/>The response context is an 
internal data structure that Druid servers use to share out-of-band information 
when sending query results to each other. It is serialized in an HTTP header 
with a maximum length of 7KiB. This error occurs when an intermediate response 
context sent from a data server (like a Historical) to the Broker exceeds this 
limit.<br/><br/>The response context is used for a variety of purposes, but the 
one most likely to generate a large context is sharing details about segments 
that move during a query. That means this error can potentially indicate that a 
very large number of segments moved in between the time a Broker issued a query 
and the time it was processed on Historicals. This should rarely, if ever, 
occur during normal operation.|
 |`Unknown exception`|500|Some other exception occurred. Check errorMessage and 
errorClass for details, although keep in mind that the contents of those fields 
are free-form and may change from release to release.|
+
+## Learn more
+[Set query context](./set-query-context.md) on how the different approaches 
for set query context.

Review Comment:
   ```suggestion
   
   To learn how to use the query context parameters, see [Set query 
context](./set-query-context.md).
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence

Review Comment:
   fix capitalization



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 

Review Comment:
   ```suggestion
   
   When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set the query context through various 
methods depending on how you submit your queries.
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence

Review Comment:
   Overall this new section is a good addition. I suggest introducing a section 
on **_how to set the query context through runtime properties_**, rather than 
talking about it for the first time in point 2.
   
   In the new section, it should include details removed from 
`sql-query-context.md` and `query-context-reference.md`.



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:
+
+1. **Built-in hard-coded defaults** — these are the system’s default values 
used if you don’t specify anything else.

Review Comment:
   Change the dash to `:` to stay consistent with the docs style



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:
+
+1. **Built-in hard-coded defaults** — these are the system’s default values 
used if you don’t specify anything else.

Review Comment:
   I don't think you need to say both "built-in" and "hard-coded"



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:

Review Comment:
   ```suggestion
   You can set the query context using various methods. For a given parameter, 
Druid determines the value to use based on the following order of precedence, 
from lowest to highest:
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:
+
+1. **Built-in hard-coded defaults** — these are the system’s default values 
used if you don’t specify anything else.
+2. **Runtime properties** — if you configure parameters as 
`druid.query.default.context.{property_key}` in Druid’s configuration files, 
these override the built-in defaults and act as your system-wide defaults.  For 
more information, see [Overriding default query context 
values](../configuration/index.md#overriding-default-query-context-values).
+
+3. **Context parameters you set in your query** — whether in the JSON 
`context` object or included directly in your queries, these override both the 
built-in defaults and the runtime properties.
+4. **SET statements** — when using SET, any parameters you set with `SET key = 
value;` commands take the highest precedence and override all other settings.

Review Comment:
   Technically (4) is a subset of (3). SET statements are context parameters 
you set in your query. Consider updating these two labels to distinguish them.
   
   Also update the description for (3), since the way it's currently described 
also _includes_ SET statements.



##########
docs/querying/query-context-reference.md:
##########
@@ -23,20 +23,26 @@ sidebar_label: "Query context"
   ~ under the License.
   -->
 
-The query context is used for various query configuration parameters. Query 
context parameters can be specified in
-the following ways:
+The query context provides runtime configuration for individual queries in 
Apache Druid. Each parameter in the query context controls a specific aspect of 
query behavior—from execution timeouts and resource limits to caching policies 
and processing strategies.
 
-- For [Druid SQL](../api-reference/sql-api.md), context parameters are 
provided either in a JSON object named `context` to the
-HTTP POST API, or as properties to the JDBC connection.
-- For [native queries](querying.md), context parameters are provided in a JSON 
object named `context`.
+Query context overrides both the default value and the runtime properties 
value in the format of

Review Comment:
   I still think this should be moved over to the new guide, since this doc 
should be limited to the reference list of parameters.



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:
+
+1. **Built-in hard-coded defaults** — these are the system’s default values 
used if you don’t specify anything else.
+2. **Runtime properties** — if you configure parameters as 
`druid.query.default.context.{property_key}` in Druid’s configuration files, 
these override the built-in defaults and act as your system-wide defaults.  For 
more information, see [Overriding default query context 
values](../configuration/index.md#overriding-default-query-context-values).
+
+3. **Context parameters you set in your query** — whether in the JSON 
`context` object or included directly in your queries, these override both the 
built-in defaults and the runtime properties.
+4. **SET statements** — when using SET, any parameters you set with `SET key = 
value;` commands take the highest precedence and override all other settings.
+
+This also means that higher precedence values overwrite lower ones. For 
example, if you set a parameter both in the runtime properties and in your 
query, Druid will use the value you set in the query.
+
+So if you don’t set a parameter anywhere, Druid uses the built-in default. If 
you set it as a runtime property, that overrides the built-in default. But if 
you explicitly set the parameter in your query or with a SET statement, that 
value overrides all others.
+
+
+## Learn more

Review Comment:
   ```suggestion
   ## Learn more
   
   For more information, see the following topics:
   
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:
+
+1. **Built-in hard-coded defaults** — these are the system’s default values 
used if you don’t specify anything else.
+2. **Runtime properties** — if you configure parameters as 
`druid.query.default.context.{property_key}` in Druid’s configuration files, 
these override the built-in defaults and act as your system-wide defaults.  For 
more information, see [Overriding default query context 
values](../configuration/index.md#overriding-default-query-context-values).
+
+3. **Context parameters you set in your query** — whether in the JSON 
`context` object or included directly in your queries, these override both the 
built-in defaults and the runtime properties.
+4. **SET statements** — when using SET, any parameters you set with `SET key = 
value;` commands take the highest precedence and override all other settings.
+
+This also means that higher precedence values overwrite lower ones. For 
example, if you set a parameter both in the runtime properties and in your 
query, Druid will use the value you set in the query.
+
+So if you don’t set a parameter anywhere, Druid uses the built-in default. If 
you set it as a runtime property, that overrides the built-in default. But if 
you explicitly set the parameter in your query or with a SET statement, that 
value overrides all others.

Review Comment:
   ```suggestion
   If you don’t set a parameter anywhere, Druid uses the built-in default. If 
you set it as a runtime property, that overrides the built-in default. If you 
explicitly set the parameter in your query, that value overrides all others.
   ```



##########
docs/querying/set-query-context.md:
##########
@@ -0,0 +1,239 @@
+---
+id: set-query-context
+title: "Set query context"
+sidebar_label: "Set query context"
+description: 
+  "This document configure and apply query context in Apache Druid 
+  to customize query execution behavior and optimize performance."
+---
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+  
+
+The query context gives you fine-grained control over how Apache Druid 
executes your individual queries. While the default settings in Druid work well 
for most queries, you can set the query context to handle specific requirements 
and optimize performance.
+
+Common use cases for the query context include:
+- Override default timeouts for long-running queries or complex aggregations.
+- Debug query performance by disabling caching during testing.
+- Configure SQL-specific behaviors like time zones for accurate time-based 
analysis.
+- Set priorities to ensure critical queries get computational resources first.
+- Adjust memory limits for queries that process large datasets.
+
+The way you set the query context depends on how you submit the query to 
Druid, whether using the web console or API.
+It also depends on whether your query is Druid SQL or a JSON-based native 
query.
+This guide shows you how to set the query context for each application.
+
+Before you begin, identify which context parameters you need to configure in 
order to establish your query context as query context carriers. For available 
parameters and their descriptions, see [Query context 
reference](query-context-reference.md).
+
+## Web console
+
+You can configure query context parameters is via the [Web 
console](../operations/web-console.md). In the web console, you can set up 
context parameters for both Druid SQL and native queries.
+
+The following steps show you how to set the query context using the web 
console:
+
+1. In the web console, select **Query** from the top-level navigation.
+
+   ![Query view](../assets/set-query-context-query-view.png)
+
+1. **Click** the **Engine** selector next to the **Run** button to choose the 
appropriate query type. Unless otherwise instructed, you can leave the engine 
as `Auto` to let Druid choose the best engine for you.
+
+   ![Engine selection](../assets/set-query-context-select-engine.png)
+
+2. Enter the query you want to run.
+
+   ![Adding query](../assets/set-query-context-insert-query.png)
+
+3. Select **Edit query context** button in the **Select language and engine** 
menu.
+
+   ![Opening context 
dialog](../assets/set-query-context-open-context-dialog.png)
+
+4. In the **Edit query context** dialog, add your context parameters as JSON 
key-value pairs and then click **Save**. For example,you can insert the 
following context parameters:
+
+   ```json
+   {
+     "timeout": 300000,
+     "useCache": false
+   }
+   ```
+
+   The web console validates the JSON object containing the query context 
parameters and highlights any syntax errors before you click **Run** the query.
+
+   ![Setting the context 
parameters](../assets/set-query-context-set-context-parameters.png)
+
+6. Click **Run** to execute your query with the specified context parameters.
+
+   ![Running the query](../assets/set-query-context-run-the-query.png)
+
+
+For more information about using the web console Query view, see [Query 
view](../operations/web-console.md#query).
+
+## Druid SQL
+When using Druid SQL programmatically—such as in applications, automated 
scripts, or database tools—you can set query context through various methods 
depending on how your queries are executed. 
+
+### HTTP API
+
+When using the HTTP API, you include query context parameters in the `context` 
object of your JSON request. For more information on how to format Druid SQL 
API requests and handle responses, see [Druid SQL 
API](../api-reference/sql-api.md).
+
+The following example sets the `sqlTimeZone` parameter:
+
+   ```json
+   {
+     "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar' AND __time 
> TIMESTAMP '2000-01-01 00:00:00'",
+     "context" : {
+       "sqlTimeZone" : "America/Los_Angeles"
+     }
+   }
+   ```
+
+Druid executes your query using the specified context parameters and return 
the results.
+
+You can set multiple context parameters in a single request:
+
+```json
+{
+  "query" : "SELECT COUNT(*) FROM data_source WHERE foo = 'bar'",
+  "context" : {
+    "timeout" : 30000,
+    "useCache" : false,
+    "sqlTimeZone" : "America/Los_Angeles"
+  }
+}
+```
+
+
+### JDBC driver API
+
+You can connect to Druid over JDBC and issue Druid SQL queries using this 
[Druid SQL JDBC driver API](../api-reference/sql-jdbc.md). When connecting to 
Druid through JDBC, you set query context parameters a JDBC connection 
properties object. This approach is useful when integrating Druid with BI tools 
or Java applications.
+
+For example, you can set query context parameters when creating your JDBC 
connection:
+
+```java
+String url = 
"jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/";;
+
+// Set any query context parameters you need here.
+Properties connectionProperties = new Properties();
+connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles");
+connectionProperties.setProperty("useCache", "false");
+
+try (Connection connection = DriverManager.getConnection(url, 
connectionProperties)) {
+  // create and execute statements, process result sets, etc
+}
+```
+
+
+### SET statements
+
+You can use the SET command to specify SQL query context parameters that 
modify the behavior of a Druid SQL query. Druid accepts one or more SET 
statements before the main SQL query. The SET command works in the both web 
console and the Druid SQL HTTP API.
+
+In the web console, you can write your SET statements followed by your query 
directly. For example, 
+
+```sql
+SET useApproximateTopN = false;
+SET sqlTimeZone = 'America/Los_Angeles';
+SET timeout = 90000;
+SELECT some_column, COUNT(*) 
+FROM druid.foo 
+WHERE other_column = 'foo' 
+GROUP BY 1 
+ORDER BY 2 DESC
+```
+
+You can also include your SET statements as part of the query string in your 
HTTP API call. For example,
+
+```bash
+curl -X POST 'http://localhost:8888/druid/v2/sql' \
+  -H 'Content-Type: application/json' \
+  -d '{
+    "query": "SET useApproximateTopN = false; SET sqlTimeZone = 
'\''America/Los_Angeles'\''; SET timeout = 90000; SELECT some_column, COUNT(*) 
FROM druid.foo WHERE other_column = '\''foo'\'' GROUP BY 1 ORDER BY 2 DESC"
+  }'
+```
+
+You can also combine SET statements with the `context` field. If you include 
both, the parameter value in SET takes precedence:
+
+```json
+{
+  "query": "SET timeout = 90000; SELECT COUNT(*) FROM data_source",
+  "context": {
+    "timeout": 30000,  // This will be overridden by SET
+    "priority": 100    // This will still apply
+  }
+}
+```
+
+For more details on how to use the SET command in your SQL query, see 
[SET](sql.md#set).
+
+:::info
+You cannot use SET statements in JDBC connections.
+:::
+
+
+## Native queries
+
+For native queries, you can include query context parameters in a JSON object 
named `context` within your query structure or through [Web 
Console](./set-query-context.md#web-console).
+
+The following example shows a native query that sets the given query id 
through context parameters from dataset `wikipedia`:
+
+```json
+{
+  "queryType": "timeseries",
+  "dataSource": "wikipedia",
+  "granularity": "day",
+  "descending": true,
+  "filter": {
+    "type": "and",
+    "fields": [
+      { "type": "selector", "dimension": "countryName", "value": "Australia" },
+      { "type": "selector", "dimension": "isAnonymous", "value": "true" }
+    ]
+  },
+  "aggregations": [
+    { "type": "count", "name": "row_count" }
+  ],
+  "intervals": ["2015-09-12T00:00:00.000/2015-09-13T00:00:00.000"],
+  "context": {
+    "queryId": "only_query_id_test"
+  }
+}
+```
+
+For more information about native queries, see [Native queries](querying.md).
+
+
+## Query Context Precedence
+
+When you set query context parameters in Druid, Druid determines which values 
to use based on the following order of precedence, from lowest to highest:
+
+1. **Built-in hard-coded defaults** — these are the system’s default values 
used if you don’t specify anything else.
+2. **Runtime properties** — if you configure parameters as 
`druid.query.default.context.{property_key}` in Druid’s configuration files, 
these override the built-in defaults and act as your system-wide defaults.  For 
more information, see [Overriding default query context 
values](../configuration/index.md#overriding-default-query-context-values).
+
+3. **Context parameters you set in your query** — whether in the JSON 
`context` object or included directly in your queries, these override both the 
built-in defaults and the runtime properties.
+4. **SET statements** — when using SET, any parameters you set with `SET key = 
value;` commands take the highest precedence and override all other settings.
+
+This also means that higher precedence values overwrite lower ones. For 
example, if you set a parameter both in the runtime properties and in your 
query, Druid will use the value you set in the query.

Review Comment:
   The first line seems redundant with the definition of "precedence"
   ```suggestion
   For example, if you set a parameter both in the runtime properties and in 
your query, Druid will use the value you set in the query.
   ```



-- 
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]

Reply via email to