Repository navigation
Expand file tree
/
Copy pathanalysis.sql
More file actions
59 lines (53 loc) · 1.81 KB
/
Copy pathanalysis.sql
File metadata and controls
59 lines (53 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- ClickStudio live-query examples.
--
-- Use Run to execute all SQL, or select SQL to run only that selection.
-- Multi-statement scripts stop at the first error.
-- The active statements are read-only. The parameter example stays commented so
-- the whole file works without extra editor state.
-- 1. Table-free smoke test.
-- Works against a fresh ClickHouse server and produces chart-friendly rows.
SELECT
toDate('2026-01-01') + toUInt32(number) AS day,
toUInt64((number + 1) * 10) AS events
FROM numbers(7)
ORDER BY day;
-- 2. Seeded local dataset.
-- npm run db:setup creates default.events with seven deterministic rows.
SELECT
day,
events,
sum(events) OVER (ORDER BY day) AS running_events
FROM default.events
ORDER BY day;
-- 3. Index-pruning example.
-- Run this statement with EXPLAIN INDEXES, EXPLAIN PLAN, or EXPLAIN PIPELINE
-- from the Run actions. default.events is ordered by day.
SELECT day, events
FROM default.events
WHERE day >= toDate('2026-01-04')
ORDER BY day;
-- 4. Exact ClickHouse values.
-- UInt64 and Decimal values must remain exact in table/export, not JS doubles.
SELECT
toUInt64('18446744073709551615') AS exact_uint64,
toDecimal128('12345678901234567890.12', 2) AS exact_decimal,
CAST(NULL AS Nullable(String)) AS missing,
['first', 'second'] AS labels;
-- 5. Read-only schema exploration.
-- This is useful for checking that system-table access is available.
SELECT
database,
name,
engine
FROM system.tables
WHERE database IN (currentDatabase(), 'system')
ORDER BY database, name
LIMIT 25;
-- 6. Named parameter binding.
-- Uncomment this statement, then provide minimum=30 in the editor parameter
-- control before running it. Values are bound on the server.
--
-- SELECT day, events
-- FROM default.events
-- WHERE events >= {minimum:UInt64}
-- ORDER BY day;