Skip to content

Commit 5a79461

Browse files
docs(workspace): document SQL Runner (#6499)
Co-Authored-By: Igor Lukanin <[email protected]>
1 parent 2c309b7 commit 5a79461

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: SQL Runner
3+
permalink: /cloud/sql-runner
4+
category: Workspace
5+
menuOrder: 6
6+
---
7+
8+
The SQL Runner is a tool that allows you to execute SQL queries from Cube Cloud
9+
on your data source or Cube Store. It can be used to inform the development of
10+
the data model, for ad-hoc querying as well as debugging SQL queries generated
11+
by Cube to execute against the data source.
12+
13+
<SuccessBox>
14+
15+
The SQL Runner is available in Cube Cloud on
16+
[all tiers](https://cube.dev/pricing).
17+
18+
</SuccessBox>
19+
20+
<Screenshot src="https://ucarecdn.com/6d443059-b990-4735-81c1-78a490aa2f25/" />
21+
22+
## Executing queries
23+
24+
To execute a query, enter the SQL query in the text area under **SQL Editor**
25+
and click <Btn>▶ Run</Btn>. The query results will be displayed under
26+
**Results**, along with the row count and query execution time:
27+
28+
<Screenshot
29+
highlight="inset(12% 2% 1% 41% round 10px)"
30+
src="https://ucarecdn.com/2f910abf-5b94-43cd-87f8-14c86bd98f77/"
31+
/>
32+
33+
## Querying a data source vs Cube Store
34+
35+
The SQL Runner can run queries against any configured data sources, which is
36+
helpful for diagnosing database-specific issues. It can also run queries against
37+
Cube Store, which is useful for testing pre-aggregations directly to see if they
38+
return expected results. You can switch data source(s) by clicking the dropdown
39+
under **Data Source**:
40+
41+
<Screenshot
42+
highlight="inset(25% 60% 53% 6% round 10px)"
43+
src="https://ucarecdn.com/5bd43e2c-c8e6-4300-a89b-036398e92175/"
44+
/>
45+
46+
## Using a Security Context
47+
48+
The SQL Runner also allows executing queries against [configured data
49+
sources][ref-conf-ref-driverfactory] using a specific security context, which is
50+
particularly convenient for debugging [queries in a multi-tenant
51+
configuration][ref-recipe-multi-src-same-model]. The SQL Runner can be
52+
configured to use predefined security contexts from
53+
[`scheduledRefreshContexts`][ref-conf-scheduled-refresh-ctx] in the `cube.js`
54+
configuration file, or a custom context can be provided as a JSON string.
55+
56+
Specifying a security context is optional, and if none is provided, the query
57+
will be executed with the default security context. If one is provided, then the
58+
**Schema Explorer** will reload to reflect the data source available to the
59+
security context.
60+
61+
[ref-conf-ref-driverfactory]: /config#options-reference-driver-factory
62+
[ref-recipe-multi-src-same-model]: /recipes/multiple-sources-same-schema
63+
64+
### <--{"id" : "Using a Security Context"}--> Scheduled Refresh Contexts
65+
66+
If you have configured
67+
[`scheduledRefreshContexts`][ref-conf-scheduled-refresh-ctx] in your deployment,
68+
you can choose a context to execute the query with. Click the dropdown under
69+
**Security Context**, then use the <Btn>Scheduled Refresh Contexts</Btn> tab to
70+
select an existing context:
71+
72+
<Screenshot src="https://ucarecdn.com/f3664be8-8214-4b27-88bb-f8cd85fc934f/" />
73+
74+
### <--{"id" : "Using a Security Context"}--> Custom Contexts
75+
76+
The SQL Runner also allows providing an ad-hoc security context as a JSON
77+
string. From the same dropdown under **Security Context**, click the <Btn>Custom
78+
Context</Btn> tab and enter a valid JSON string and click <Btn>Apply</Btn>:
79+
80+
<Screenshot src="https://ucarecdn.com/955fa2c7-31c5-459e-adfb-498fbaf7bbb6/" />
81+
82+
## Viewing schema details
83+
84+
The Schema Explorer allows you to view details of the data source's schema,
85+
including tables and their columns and types. This is useful for ensuring that
86+
properties of data models match the underlying schema (i.e. a `number` property
87+
in a data model should be a `numeric`).
88+
89+
<Screenshot
90+
highlight="inset(37% 60% 0% 6% round 10px)"
91+
src="https://ucarecdn.com/c2735f7c-d5e7-4b6b-903b-8d0db07b668e/"
92+
/>
93+
94+
[cubecloud-signup]: https://cubecloud.dev/auth/signup
95+
[ref-conf-scheduled-refresh-ctx]:
96+
/config#options-reference-scheduled-refresh-contexts

0 commit comments

Comments
 (0)