create-dql-app 0.11.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +123 -0
- package/README.md +3 -3
- package/bin/create-dql-app.mjs +23 -6
- package/package.json +15 -8
- package/templates/empty/README.md +1 -1
- package/templates/empty/dql.config.json +13 -0
- package/templates/empty/notebooks/welcome.dqlnb +20 -0
- package/templates/empty/package.json +13 -0
- package/templates/jaffle-shop/README.md +26 -12
- package/templates/jaffle-shop/blocks/revenue_by_segment.dql +26 -0
- package/templates/jaffle-shop/dashboards/overview.dql +24 -19
- package/templates/jaffle-shop/dql.config.json +20 -0
- package/templates/jaffle-shop/notebooks/welcome.dqlnb +32 -0
- package/templates/jaffle-shop/package.json +16 -0
- package/templates/empty/cdql.yaml +0 -13
- package/templates/empty/notebooks/welcome.dql +0 -17
- package/templates/jaffle-shop/blocks/finance/revenue_by_segment.dql +0 -23
- package/templates/jaffle-shop/cdql.yaml +0 -17
- package/templates/jaffle-shop/notebooks/welcome.dql +0 -44
package/LICENSE
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship.
|
|
41
|
+
|
|
42
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
43
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
44
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
45
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
46
|
+
on behalf of the copyright owner.
|
|
47
|
+
|
|
48
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
49
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
50
|
+
incorporated within the Work.
|
|
51
|
+
|
|
52
|
+
2. Grant of Copyright License.
|
|
53
|
+
|
|
54
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
55
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
56
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
57
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
58
|
+
Derivative Works in Source or Object form.
|
|
59
|
+
|
|
60
|
+
3. Grant of Patent License.
|
|
61
|
+
|
|
62
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
63
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
64
|
+
irrevocable patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution.
|
|
68
|
+
|
|
69
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
70
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
71
|
+
provided that You meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
74
|
+
this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
77
|
+
You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
80
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
81
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
82
|
+
of the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
85
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
86
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
87
|
+
that do not pertain to any part of the Derivative Works.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
92
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
93
|
+
conditions of this License, without any additional terms or conditions.
|
|
94
|
+
|
|
95
|
+
6. Trademarks.
|
|
96
|
+
|
|
97
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
98
|
+
service marks, or product names of the Licensor, except as required for
|
|
99
|
+
reasonable and customary use in describing the origin of the Work.
|
|
100
|
+
|
|
101
|
+
7. Disclaimer of Warranty.
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
104
|
+
Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
105
|
+
express or implied, including, without limitation, any warranties or conditions
|
|
106
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
107
|
+
PURPOSE.
|
|
108
|
+
|
|
109
|
+
8. Limitation of Liability.
|
|
110
|
+
|
|
111
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
112
|
+
contract, or otherwise, unless required by applicable law, shall any Contributor
|
|
113
|
+
be liable to You for damages, including any direct, indirect, special,
|
|
114
|
+
incidental, or consequential damages of any character arising as a result of this
|
|
115
|
+
License or out of the use or inability to use the Work.
|
|
116
|
+
|
|
117
|
+
9. Accepting Warranty or Additional Liability.
|
|
118
|
+
|
|
119
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
120
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
121
|
+
other liability obligations and/or rights consistent with this License.
|
|
122
|
+
|
|
123
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -31,9 +31,9 @@ npx create-dql-app finance-reports --template empty
|
|
|
31
31
|
|
|
32
32
|
## Docs
|
|
33
33
|
|
|
34
|
-
- [Quickstart](https://
|
|
35
|
-
- [Concepts](https://
|
|
36
|
-
- [Connect your own warehouse](https://
|
|
34
|
+
- [Quickstart](https://github.com/duckcode-ai/dql/blob/main/docs/01-quickstart.md)
|
|
35
|
+
- [Concepts](https://github.com/duckcode-ai/dql/blob/main/docs/02-concepts.md)
|
|
36
|
+
- [Connect your own warehouse](https://github.com/duckcode-ai/dql/blob/main/docs/guides/connect-warehouse.md)
|
|
37
37
|
|
|
38
38
|
## License
|
|
39
39
|
|
package/bin/create-dql-app.mjs
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
import { spawnSync } from 'node:child_process';
|
|
14
14
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
15
|
-
import { dirname, join, resolve, basename } from 'node:path';
|
|
15
|
+
import { dirname, join, resolve, basename, relative } from 'node:path';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
17
|
|
|
18
|
-
const VERSION = '0.
|
|
18
|
+
const VERSION = '1.0.1';
|
|
19
19
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
20
|
const TEMPLATES_DIR = resolve(__dirname, '..', 'templates');
|
|
21
21
|
|
|
@@ -100,6 +100,13 @@ function detectDbtSibling(target) {
|
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
function detectPackageManager() {
|
|
104
|
+
const ua = process.env.npm_config_user_agent ?? '';
|
|
105
|
+
if (ua.startsWith('pnpm/')) return 'pnpm';
|
|
106
|
+
if (ua.startsWith('yarn/')) return 'yarn';
|
|
107
|
+
return 'npm';
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
async function main() {
|
|
104
111
|
const args = parseArgs(process.argv.slice(2));
|
|
105
112
|
if (!args.dir) {
|
|
@@ -129,32 +136,42 @@ async function main() {
|
|
|
129
136
|
copyDir(tplDir, target);
|
|
130
137
|
|
|
131
138
|
const dbtSibling = detectDbtSibling(target);
|
|
139
|
+
// Store dbt path as relative-to-project — keeps dql.config.json portable.
|
|
140
|
+
const dbtRel = dbtSibling ? (relative(target, dbtSibling) || '.') : '../my-dbt-project';
|
|
132
141
|
const vars = {
|
|
133
142
|
PROJECT_NAME: projectName,
|
|
134
143
|
YEAR: String(new Date().getFullYear()),
|
|
135
|
-
DBT_PROJECT_DIR:
|
|
144
|
+
DBT_PROJECT_DIR: dbtRel,
|
|
136
145
|
DBT_DETECTED: dbtSibling ? 'true' : 'false',
|
|
137
146
|
};
|
|
138
147
|
for (const f of walk(target)) substitute(f, vars);
|
|
139
148
|
|
|
140
149
|
if (dbtSibling) {
|
|
141
150
|
console.log(c.dim(` detected sibling dbt project at ${dbtSibling}`));
|
|
142
|
-
console.log(c.dim(` wired into
|
|
151
|
+
console.log(c.dim(` wired into dql.config.json — run 'dql sync dbt' to import\n`));
|
|
143
152
|
}
|
|
144
153
|
|
|
145
154
|
// Best-effort: try to run `git init` so users get a clean first commit.
|
|
146
155
|
const gitResult = spawnSync('git', ['init', '-q'], { cwd: target });
|
|
147
156
|
if (gitResult.status === 0) console.log(c.dim(' initialized git repo'));
|
|
148
157
|
|
|
158
|
+
const pm = detectPackageManager();
|
|
159
|
+
const installCmd = pm === 'npm' ? 'npm install' : `${pm} install`;
|
|
160
|
+
const runCmd = pm === 'npm' ? 'npm run notebook' : `${pm} notebook`;
|
|
161
|
+
const dbtTip = dbtSibling
|
|
162
|
+
? `\n\n${c.dim('Tip:')} run ${c.bold('dbt parse')} inside ${c.dim(dbtSibling)}\n first, then ${c.bold(pm === 'npm' ? 'npm run sync' : `${pm} sync`)} to import the dbt DAG.`
|
|
163
|
+
: '';
|
|
164
|
+
|
|
149
165
|
console.log(`
|
|
150
166
|
${c.green('✓ Ready.')} Next steps:
|
|
151
167
|
|
|
152
168
|
${c.bold(`cd ${args.dir}`)}
|
|
153
|
-
${c.bold(
|
|
169
|
+
${c.bold(installCmd)}
|
|
170
|
+
${c.bold(runCmd)}${dbtTip}
|
|
154
171
|
|
|
155
172
|
Your notebook will open at ${c.cyan('http://localhost:5173')}.
|
|
156
173
|
|
|
157
|
-
Docs: ${c.cyan('https://
|
|
174
|
+
Docs: ${c.cyan('https://github.com/duckcode-ai/dql')}
|
|
158
175
|
Issues: ${c.cyan('https://github.com/duckcode-ai/dql/issues')}
|
|
159
176
|
`);
|
|
160
177
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-dql-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Scaffold a new DQL project. Run with: npx create-dql-app <name>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "DuckCode AI Labs",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://github.com/duckcode-ai/dql",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/duckcode-ai/dql.git",
|
|
11
11
|
"directory": "packages/create-dql-app"
|
|
12
12
|
},
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dql",
|
|
15
|
+
"dbt",
|
|
16
|
+
"analytics",
|
|
17
|
+
"notebook",
|
|
18
|
+
"semantic-layer",
|
|
19
|
+
"lineage"
|
|
20
|
+
],
|
|
14
21
|
"bin": {
|
|
15
22
|
"create-dql-app": "./bin/create-dql-app.mjs"
|
|
16
23
|
},
|
|
@@ -20,14 +27,14 @@
|
|
|
20
27
|
"README.md"
|
|
21
28
|
],
|
|
22
29
|
"type": "module",
|
|
23
|
-
"scripts": {
|
|
24
|
-
"test": "node test/smoke.mjs",
|
|
25
|
-
"build": "echo 'no build step — pure JS'"
|
|
26
|
-
},
|
|
27
30
|
"engines": {
|
|
28
31
|
"node": ">=20"
|
|
29
32
|
},
|
|
30
33
|
"publishConfig": {
|
|
31
34
|
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"test": "node test/smoke.mjs",
|
|
38
|
+
"build": "echo 'no build step — pure JS'"
|
|
32
39
|
}
|
|
33
|
-
}
|
|
40
|
+
}
|
|
@@ -5,7 +5,7 @@ An empty DQL project, scaffolded by `create-dql-app --template empty`.
|
|
|
5
5
|
## Connect your warehouse
|
|
6
6
|
|
|
7
7
|
Edit `cdql.yaml` — DQL ships 15 drivers out of the box:
|
|
8
|
-
[docs
|
|
8
|
+
[docs/reference/connectors.md](https://github.com/duckcode-ai/dql/blob/main/docs/reference/connectors.md).
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
11
|
npx @duckcodeailabs/dql-cli test-connection
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"metadata": {
|
|
4
|
+
"title": "{{PROJECT_NAME}} — Welcome",
|
|
5
|
+
"description": "Replace this cell with your first query."
|
|
6
|
+
},
|
|
7
|
+
"cells": [
|
|
8
|
+
{
|
|
9
|
+
"id": "intro",
|
|
10
|
+
"type": "markdown",
|
|
11
|
+
"source": "# {{PROJECT_NAME}}\n\nWelcome to DQL. Connect a warehouse in `dql.config.json`, then edit the cell below."
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": "first_query",
|
|
15
|
+
"type": "sql",
|
|
16
|
+
"title": "First query",
|
|
17
|
+
"source": "select 1 as hello"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -5,30 +5,44 @@ A DQL analytics project, scaffolded by `create-dql-app`.
|
|
|
5
5
|
## Run
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npm install
|
|
9
|
+
npm run notebook
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
Opens the notebook at <http://localhost:5173>.
|
|
12
|
+
Opens the notebook at <http://localhost:5173>. (`pnpm install && pnpm notebook`
|
|
13
|
+
works too.)
|
|
12
14
|
|
|
13
15
|
## Layout
|
|
14
16
|
|
|
15
17
|
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
dql.config.json project config (connections, dbt, semantic layer)
|
|
19
|
+
package.json npm scripts — `notebook`, `compile`, `sync`, `doctor`
|
|
20
|
+
notebooks/ .dqlnb notebooks (JSON format)
|
|
21
|
+
blocks/ certified reusable .dql blocks
|
|
19
22
|
semantic-layer/ metrics + dimensions authored locally
|
|
20
23
|
dashboards/ compiled static HTML dashboards (git-ignored)
|
|
21
24
|
```
|
|
22
25
|
|
|
26
|
+
## Using with dbt
|
|
27
|
+
|
|
28
|
+
If your dbt project is a sibling (e.g. `../dbt`), it was auto-wired into
|
|
29
|
+
`dql.config.json` under the `dbt:` key. Then:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
(cd ../dbt && dbt parse) # produces target/manifest.json
|
|
33
|
+
npm run sync # refreshes the DQL cache from dbt
|
|
34
|
+
npm run compile # builds dql-manifest.json with lineage
|
|
35
|
+
```
|
|
36
|
+
|
|
23
37
|
## Next steps
|
|
24
38
|
|
|
25
|
-
1. **Run the welcome notebook** — `notebooks/welcome.
|
|
26
|
-
2. **Connect your warehouse** — [docs
|
|
27
|
-
3. **Import your dbt project** — [docs
|
|
28
|
-
4. **Author a certified block** — [docs
|
|
39
|
+
1. **Run the welcome notebook** — `notebooks/welcome.dqlnb`
|
|
40
|
+
2. **Connect your warehouse** — [docs/guides/connect-warehouse.md](https://github.com/duckcode-ai/dql/blob/main/docs/guides/connect-warehouse.md)
|
|
41
|
+
3. **Import your dbt project** — [docs/guides/import-dbt.md](https://github.com/duckcode-ai/dql/blob/main/docs/guides/import-dbt.md)
|
|
42
|
+
4. **Author a certified block** — [docs/guides/authoring-blocks.md](https://github.com/duckcode-ai/dql/blob/main/docs/guides/authoring-blocks.md)
|
|
29
43
|
|
|
30
44
|
## Learn
|
|
31
45
|
|
|
32
|
-
- [Quickstart](https://
|
|
33
|
-
- [Concepts](https://
|
|
34
|
-
- [CLI reference](https://
|
|
46
|
+
- [Quickstart](https://github.com/duckcode-ai/dql/blob/main/docs/01-quickstart.md)
|
|
47
|
+
- [Concepts](https://github.com/duckcode-ai/dql/blob/main/docs/02-concepts.md)
|
|
48
|
+
- [CLI reference](https://github.com/duckcode-ai/dql/blob/main/docs/reference/cli.md)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// dql-format: 1
|
|
2
|
+
|
|
3
|
+
block "Revenue by segment" {
|
|
4
|
+
domain = "finance"
|
|
5
|
+
type = "custom"
|
|
6
|
+
description = "Gross revenue grouped by customer segment."
|
|
7
|
+
tags = ["revenue", "sample"]
|
|
8
|
+
query = """
|
|
9
|
+
SELECT
|
|
10
|
+
c.customer_segment AS segment,
|
|
11
|
+
SUM(o.amount) AS revenue,
|
|
12
|
+
COUNT(DISTINCT o.customer_id) AS customers
|
|
13
|
+
FROM orders o
|
|
14
|
+
JOIN customers c ON c.customer_id = o.customer_id
|
|
15
|
+
GROUP BY 1
|
|
16
|
+
ORDER BY revenue DESC
|
|
17
|
+
"""
|
|
18
|
+
visualization {
|
|
19
|
+
chart = "bar"
|
|
20
|
+
x = segment
|
|
21
|
+
y = revenue
|
|
22
|
+
}
|
|
23
|
+
tests {
|
|
24
|
+
assert row_count > 0
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
// dql-format: 1
|
|
2
2
|
|
|
3
|
-
dashboard
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
dashboard "{{PROJECT_NAME}} — Overview" {
|
|
4
|
+
chart.kpi(
|
|
5
|
+
SELECT SUM(amount) as revenue FROM orders,
|
|
6
|
+
metrics = ["revenue"]
|
|
7
|
+
)
|
|
8
|
+
chart.bar(
|
|
9
|
+
SELECT customer_id, SUM(amount) as spend
|
|
10
|
+
FROM orders
|
|
11
|
+
GROUP BY customer_id
|
|
12
|
+
ORDER BY spend DESC
|
|
13
|
+
LIMIT 10,
|
|
14
|
+
x = customer_id,
|
|
15
|
+
y = spend,
|
|
16
|
+
title = "Top 10 customers by spend"
|
|
17
|
+
)
|
|
18
|
+
chart.line(
|
|
19
|
+
SELECT order_date, SUM(amount) as revenue
|
|
20
|
+
FROM orders
|
|
21
|
+
GROUP BY order_date
|
|
22
|
+
ORDER BY order_date,
|
|
23
|
+
x = order_date,
|
|
24
|
+
y = revenue,
|
|
25
|
+
title = "Daily revenue"
|
|
26
|
+
)
|
|
7
27
|
}
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
type: markdown
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# Overview — {{YEAR}}
|
|
14
|
-
|
|
15
|
-
Compiled with `dql compile dashboards/overview.dql --out build/`. Host the
|
|
16
|
-
resulting HTML anywhere.
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
type: dql
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
@block("revenue_by_segment")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"project": "{{PROJECT_NAME}}",
|
|
3
|
+
"connections": {
|
|
4
|
+
"default": {
|
|
5
|
+
"driver": "duckdb",
|
|
6
|
+
"filepath": ":memory:"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"semanticLayer": {
|
|
10
|
+
"provider": "dql",
|
|
11
|
+
"path": "semantic-layer"
|
|
12
|
+
},
|
|
13
|
+
"dbt": {
|
|
14
|
+
"projectDir": "{{DBT_PROJECT_DIR}}",
|
|
15
|
+
"manifestPath": "target/manifest.json"
|
|
16
|
+
},
|
|
17
|
+
"governance": {
|
|
18
|
+
"required_fields": ["domain", "owner", "description"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"metadata": {
|
|
4
|
+
"title": "{{PROJECT_NAME}} — Welcome",
|
|
5
|
+
"description": "A tour of DQL in four cells. Run them top-to-bottom with Cmd+Enter."
|
|
6
|
+
},
|
|
7
|
+
"cells": [
|
|
8
|
+
{
|
|
9
|
+
"id": "intro",
|
|
10
|
+
"type": "markdown",
|
|
11
|
+
"source": "# Welcome to {{PROJECT_NAME}}\n\nThis notebook runs against a DuckDB-backed Jaffle Shop dataset — the same demo data dbt ships.\n\n- Run each cell with `Cmd/Ctrl + Enter`.\n- Charts render inline from SQL results.\n- The certified block in cell 4 lives in `blocks/revenue_by_segment.dql` and can be reused across notebooks and dashboards."
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": "orders_overview",
|
|
15
|
+
"type": "sql",
|
|
16
|
+
"title": "Orders overview",
|
|
17
|
+
"source": "select\n count(*) as total_orders,\n count(distinct customer_id) as unique_customers,\n sum(amount) as lifetime_revenue\nfrom orders"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "daily_revenue",
|
|
21
|
+
"type": "sql",
|
|
22
|
+
"title": "Daily revenue",
|
|
23
|
+
"source": "select\n order_date,\n sum(amount) as revenue\nfrom orders\ngroup by 1\norder by 1"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "revenue_by_segment",
|
|
27
|
+
"type": "dql",
|
|
28
|
+
"title": "Revenue by segment (certified block)",
|
|
29
|
+
"source": "@block(\"Revenue by segment\")"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PROJECT_NAME}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "DQL analytics project.",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"notebook": "dql notebook",
|
|
8
|
+
"compile": "dql compile",
|
|
9
|
+
"sync": "dql sync dbt",
|
|
10
|
+
"doctor": "dql doctor",
|
|
11
|
+
"test": "dql test"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@duckcodeailabs/dql-cli": "^1.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
project:
|
|
2
|
-
name: {{PROJECT_NAME}}
|
|
3
|
-
version: 1
|
|
4
|
-
|
|
5
|
-
connections:
|
|
6
|
-
# Swap this for your warehouse — postgres, snowflake, bigquery, etc.
|
|
7
|
-
# See https://docs.duckcode.ai/reference/connectors/
|
|
8
|
-
default:
|
|
9
|
-
driver: duckdb
|
|
10
|
-
path: ./warehouse.duckdb
|
|
11
|
-
|
|
12
|
-
governance:
|
|
13
|
-
required_fields: [domain, owner, description]
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// dql-format: 1
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
type: markdown
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# {{PROJECT_NAME}}
|
|
8
|
-
|
|
9
|
-
Welcome to DQL. Start by connecting a warehouse (`cdql.yaml`), then replace
|
|
10
|
-
this cell with your first query.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
type: sql
|
|
14
|
-
name: first_query
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
select 1 as hello;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// dql-format: 1
|
|
2
|
-
|
|
3
|
-
block revenue_by_segment {
|
|
4
|
-
domain: "finance"
|
|
5
|
-
owner: "analytics@{{PROJECT_NAME}}.local"
|
|
6
|
-
tags: ["revenue", "sample"]
|
|
7
|
-
description: "Gross revenue grouped by customer segment."
|
|
8
|
-
|
|
9
|
-
query: |
|
|
10
|
-
select
|
|
11
|
-
c.segment,
|
|
12
|
-
sum(o.order_total) as revenue,
|
|
13
|
-
count(distinct o.customer_id) as customers
|
|
14
|
-
from orders o
|
|
15
|
-
join customers c on c.customer_id = o.customer_id
|
|
16
|
-
group by 1
|
|
17
|
-
order by revenue desc
|
|
18
|
-
|
|
19
|
-
visualization: bar(x: "segment", y: "revenue", title: "Revenue by segment")
|
|
20
|
-
|
|
21
|
-
tests:
|
|
22
|
-
- row_count > 0
|
|
23
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
project:
|
|
2
|
-
name: {{PROJECT_NAME}}
|
|
3
|
-
version: 1
|
|
4
|
-
|
|
5
|
-
connections:
|
|
6
|
-
default:
|
|
7
|
-
driver: duckdb
|
|
8
|
-
path: ./warehouse.duckdb
|
|
9
|
-
|
|
10
|
-
# Remove this block if you aren't using dbt. DQL reads target/manifest.json
|
|
11
|
-
# directly — see https://docs.duckcode.ai/guides/import-dbt/
|
|
12
|
-
dbt:
|
|
13
|
-
projectDir: {{DBT_PROJECT_DIR}}
|
|
14
|
-
manifestPath: target/manifest.json
|
|
15
|
-
|
|
16
|
-
governance:
|
|
17
|
-
required_fields: [domain, owner, description]
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// dql-format: 1
|
|
2
|
-
|
|
3
|
-
// Welcome to DQL. This notebook runs against a DuckDB-backed Jaffle Shop
|
|
4
|
-
// dataset — the same demo data dbt ships. Press ⌘↵ on each cell.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
type: markdown
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# {{PROJECT_NAME}}
|
|
11
|
-
|
|
12
|
-
A tour of DQL in four cells. Run them top-to-bottom.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
type: sql
|
|
16
|
-
name: orders_overview
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
select
|
|
20
|
-
count(*) as total_orders,
|
|
21
|
-
count(distinct customer_id) as unique_customers,
|
|
22
|
-
sum(order_total) as lifetime_revenue
|
|
23
|
-
from orders;
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
type: sql
|
|
27
|
-
name: daily_revenue
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
select
|
|
31
|
-
order_date,
|
|
32
|
-
sum(order_total) as revenue
|
|
33
|
-
from orders
|
|
34
|
-
group by 1
|
|
35
|
-
order by 1;
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
type: dql
|
|
39
|
-
name: revenue_by_segment
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
// Reference a certified block. The block lives in blocks/finance/ and can
|
|
43
|
-
// be reused across notebooks, dashboards, and other blocks.
|
|
44
|
-
@block("revenue_by_segment")
|