mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-28 19:00:39 +00:00
* feat: ordered builder wip * feat: impl RegionScanner for SeqScan * feat: implement scan_partition and build_stream * chore: return SeqScan as RegionScanner * fix: group parts * feat: split parts * chore: reader metrics * chore: metrics * chore: remove unused codes * chore: support holding a group of ranges in ScanPart * feat: group ScanParts to ScanParts * feat: impl SeqScanner again * chore: observe build cost in ScannerMetrics * chore: fix compiler warnings * style: fix clippy * docs: update config docs * chore: forward DisplayAs to scanner * test: update sqlness tests * chore: update debug fmt * chore: custom debug for timestamp fix test compiling issue with common-macro when running cargo nextest -p common-time * chore: update debug format * feat: update fmt for scan part * chore: fix warning * fix: sanitize parallelism * feat: split parts * test: fix config api test * feat: update logs * chore: Revert "chore: remove unused codes" This reverts commit b548b30a01eeded59b1a0a8d89f9293ca63afc41. * chore: Revert "docs: update config docs" This reverts commit a7997e78d6ddcf635560574de8c1948c495bdd12. * feat: each partition scan files in parallel * test: fix config api test * docs: fix typo * chore: address comments, simplify tests * feat: global semaphore * feat: always spawn task * chore: simplify default explain output format * handle output partiton number is 0 Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix typo Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
86 lines
2.6 KiB
Plaintext
86 lines
2.6 KiB
Plaintext
CREATE TABLE host (
|
|
ts timestamp(3) time index,
|
|
host STRING PRIMARY KEY,
|
|
val BIGINT,
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO TABLE host VALUES
|
|
(0, 'host1', 0),
|
|
(5000, 'host1', null),
|
|
(10000, 'host1', 1),
|
|
(15000, 'host1', null),
|
|
(20000, 'host1', 2),
|
|
(0, 'host2', 3),
|
|
(5000, 'host2', null),
|
|
(10000, 'host2', 4),
|
|
(15000, 'host2', null),
|
|
(20000, 'host2', 5);
|
|
|
|
Affected Rows: 10
|
|
|
|
-- Test range query in nest sql
|
|
SELECT ts, host, foo FROM (SELECT ts, host, min(val) RANGE '5s' AS foo FROM host ALIGN '5s') WHERE host = 'host1' ORDER BY host, ts;
|
|
|
|
+---------------------+-------+-----+
|
|
| ts | host | foo |
|
|
+---------------------+-------+-----+
|
|
| 1970-01-01T00:00:00 | host1 | 0 |
|
|
| 1970-01-01T00:00:05 | host1 | |
|
|
| 1970-01-01T00:00:10 | host1 | 1 |
|
|
| 1970-01-01T00:00:15 | host1 | |
|
|
| 1970-01-01T00:00:20 | host1 | 2 |
|
|
+---------------------+-------+-----+
|
|
|
|
SELECT ts, b, min(c) RANGE '5s' FROM (SELECT ts, host AS b, val AS c FROM host WHERE host = 'host1') ALIGN '5s' BY (b) ORDER BY b, ts;
|
|
|
|
+---------------------+-------+-----------------+
|
|
| ts | b | MIN(c) RANGE 5s |
|
|
+---------------------+-------+-----------------+
|
|
| 1970-01-01T00:00:00 | host1 | 0 |
|
|
| 1970-01-01T00:00:05 | host1 | |
|
|
| 1970-01-01T00:00:10 | host1 | 1 |
|
|
| 1970-01-01T00:00:15 | host1 | |
|
|
| 1970-01-01T00:00:20 | host1 | 2 |
|
|
+---------------------+-------+-----------------+
|
|
|
|
-- Test EXPLAIN and ANALYZE
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (metrics.*) REDACTED
|
|
EXPLAIN SELECT ts, host, min(val) RANGE '5s' FROM host ALIGN '5s';
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| RangeSelect: range_exprs=[MIN(host.val) RANGE 5s], align=5000ms, align_to=0ms, align_by=[host.host], time_index=ts |
|
|
|_|_MergeScan [is_placeholder=false]_|
|
|
| physical_plan | RangeSelectExec: range_expr=[MIN(host.val) RANGE 5s], align=5000ms, align_to=0ms, align_by=[host@1], time_index=ts |
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (metrics.*) REDACTED
|
|
EXPLAIN ANALYZE SELECT ts, host, min(val) RANGE '5s' FROM host ALIGN '5s';
|
|
|
|
+-+-+-+
|
|
| stage | node | plan_|
|
|
+-+-+-+
|
|
| 0_| 0_|_RangeSelectExec: range_expr=[MIN(host.val) RANGE 5s], align=5000ms, align_to=0ms, align_by=[host@1], time_index=ts REDACTED
|
|
|_|_|_MergeScanExec: REDACTED
|
|
|_|_|_|
|
|
| 1_| 0_|_SeqScan: partition_count=1 (1 memtables, 0 file ranges) REDACTED
|
|
|_|_|_|
|
|
|_|_| Total rows: 10_|
|
|
+-+-+-+
|
|
|
|
DROP TABLE host;
|
|
|
|
Affected Rows: 0
|
|
|