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
feat: Add SQL queries support in /v1/sql endpoint (#9301)
* refactor(cubesql): Use &str instead of &String
* refactor(backend-native): Extract create_session function
* refactor(backend-native): Extract with_session function
* refactor(cubesql): Extract QueryPlan::try_as_logical_plan
* feat: Add SQL queries support in /v1/sql endpoint
* Add docs
* Remove mention of data_source and query_plan response fields from /v1/sql docs
---------
Co-authored-by: Igor Lukanin <igor@cube.dev>
Using this endpoint to take the SQL query and execute it against the data source directly
108
+
is not recommended as it bypasses Cube's caching layer and other optimizations.
107
109
108
-
Response
110
+
Request parameters:
109
111
110
-
-`sql` - JSON Object with the following properties
111
-
-`sql` - Formatted SQL query with parameters
112
-
-`order` - Order fields and direction used in SQL query
113
-
-`cacheKeyQueries` - Key names and TTL of Cube data cache
114
-
-`preAggregations` - SQL queries used to build pre-aggregation tables
112
+
| Parameter, type | Description | Required |
113
+
| --- | --- | --- |
114
+
|`format`, `string`| Query format:<br/>`sql` for [SQL API][ref-sql-api] queries,<br/>`rest` for [REST API][ref-rest-api] queries (default) | ❌ No |
115
+
|`query`, `string`| Query as an URL-encoded JSON object or SQL query | ✅ Yes |
116
+
|`disable_post_processing`, `boolean`| Flag that affects query planning, `true` or `false`| ❌ No |
115
117
116
-
Example request:
118
+
If `disable_post_processing` is set to `true`, Cube will try to generate the SQL
119
+
as if the query is run without [post-processing][ref-query-wpp], i.e., if it's run as a
120
+
query with [pushdown][ref-query-wpd].
121
+
122
+
<WarningBox>
123
+
124
+
Currently, the `disable_post_processing` parameter is not yet supported.
125
+
126
+
</WarningBox>
127
+
128
+
The response will contain a JSON object with the following properties under the `sql` key:
129
+
130
+
| Property, type | Description |
131
+
| --- | --- |
132
+
|`status`, `string`| Query planning status, `ok` or `error`|
133
+
|`sql`, `array`| Two-element array (see below) |
134
+
|`sql[0]`, `string`| Generated query with parameter placeholders |
135
+
|`sql[1]`, <nobr>`array` or `object`</nobr> | Generated query parameters |
136
+
137
+
For queries with the `sql` format, the response will also include the following additional
138
+
properties under the `sql` key:
139
+
140
+
| Property, type | Description |
141
+
| --- | --- |
142
+
|`query_type`, `string`|`regular` for [regular][ref-regular-queries] queries,<br/>`post_processing` for queries with [post-processing][ref-query-wpp],<br/>`pushdown` for queries with [pushdown][ref-query-wpd]|
143
+
144
+
For queries with the `sql` format, in case of an error, the response will only contain
145
+
`status`, `query_type`, and `error` properties.
146
+
147
+
For example, an error will be returned if `disable_post_processing` was set to `true` but
0 commit comments