You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Add /query/sql endpoint and RETURN DISTINCT to wiki
- Document POST /query/sql production endpoint with array format
- Add examples for curl, Python, PowerShell
- Document role management (SET ROLE in array)
- Add RETURN DISTINCT documentation with use cases
- Note distinction between /query?sql_only=true (deprecated) vs /query/sql (preferred)
-`parameters` (object, optional): Query parameters for `$param` placeholders
199
+
-`view_parameters` (object, optional): Parameters for parameterized views
200
+
-`role` (string, optional): ClickHouse role for RBAC
201
+
-`include_plan` (boolean, optional): Include logical plan in response (default: false)
202
+
203
+
**Response:**
204
+
```json
205
+
{
206
+
"cypher_query": "MATCH (u:User)-[:FOLLOWS]->(f:User) WHERE u.name = 'Alice' RETURN f.name",
207
+
"target_database": "clickhouse",
208
+
"sql": [
209
+
"SET ROLE analyst",
210
+
"SELECT f.full_name AS \"f.name\" FROM users AS u INNER JOIN follows ON follows.follower_id = u.user_id INNER JOIN users AS f ON f.user_id = follows.followed_id WHERE u.full_name = 'Alice'"
211
+
],
212
+
"role": "analyst",
213
+
"metadata": {
214
+
"query_type": "read",
215
+
"cache_status": "HIT",
216
+
"parse_time_ms": 0.152,
217
+
"planning_time_ms": 2.341,
218
+
"sql_generation_time_ms": 0.892,
219
+
"total_time_ms": 3.385
220
+
}
221
+
}
222
+
```
223
+
224
+
**Key Features:**
225
+
-**Array Format**: SQL returned as array of statements to execute in order
226
+
-**Role Management**: Includes `SET ROLE` statement when role parameter provided
227
+
-**No Execution**: SQL is generated but not executed against ClickHouse
228
+
-**Performance Metrics**: Detailed timing breakdown for optimization
229
+
-**Cache Status**: Shows if SQL was retrieved from query cache
230
+
231
+
**Use Cases:**
232
+
-**Query Debugging**: Inspect generated SQL before execution
233
+
-**External Execution**: Use SQL in other tools or pipelines
> **Note**: The older `/query?sql_only=true` endpoint returns SQL as a single string in `generated_sql` field. The `/query/sql` endpoint is preferred as it returns an array and includes role management statements.
0 commit comments