From bcd8e49b00dcde82960b129247af28a07c601aab Mon Sep 17 00:00:00 2001 From: discord9 Date: Wed, 22 Apr 2026 22:18:27 +0800 Subject: [PATCH] chore: more test Signed-off-by: discord9 --- .../optimizer/windowed_sort_nanos.result | 79 +++++++++++++++++++ .../optimizer/windowed_sort_nanos.sql | 27 +++++++ .../optimizer/windowed_sort_nanos.result | 78 ++++++++++++++++++ .../optimizer/windowed_sort_nanos.sql | 27 +++++++ 4 files changed, 211 insertions(+) create mode 100644 tests/cases/distributed/optimizer/windowed_sort_nanos.result create mode 100644 tests/cases/distributed/optimizer/windowed_sort_nanos.sql create mode 100644 tests/cases/standalone/optimizer/windowed_sort_nanos.result create mode 100644 tests/cases/standalone/optimizer/windowed_sort_nanos.sql diff --git a/tests/cases/distributed/optimizer/windowed_sort_nanos.result b/tests/cases/distributed/optimizer/windowed_sort_nanos.result new file mode 100644 index 0000000000..2310ec8f28 --- /dev/null +++ b/tests/cases/distributed/optimizer/windowed_sort_nanos.result @@ -0,0 +1,79 @@ +create table `a_ms` (`value` double, `status` bigint, ts timestamp(3) time index); + +Affected Rows: 0 + +INSERT INTO `a_ms` (`value`, `status`, `ts`) VALUES +(46.82, 200, '2026-03-12T08:00:05.123+08:00'), +(46.84, 200, '2026-03-12T08:00:15.234+08:00'), +(46.85, 200, '2026-03-12T08:00:25.345+08:00'), +(46.86, 200, '2026-03-12T08:00:35.456+08:00'), +(46.88, 200, '2026-03-12T08:00:45.567+08:00'), +(46.89, 200, '2026-03-12T08:00:55.678+08:00'), +(46.91, 200, '2026-03-12T08:01:05.789+08:00'), +(46.90, 200, '2026-03-12T08:01:15.890+08:00'), +(46.87, 200, '2026-03-12T08:01:25.901+08:00'), +(46.85, 200, '2026-03-12T08:01:35.999+08:00'); + +Affected Rows: 10 + +select ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + ++-------------------------+--------+-------+ +| ts | status | value | ++-------------------------+--------+-------+ +| 2026-03-12T00:00:05.123 | 200 | 46.82 | +| 2026-03-12T00:00:15.234 | 200 | 46.84 | +| 2026-03-12T00:00:25.345 | 200 | 46.85 | +| 2026-03-12T00:00:35.456 | 200 | 46.86 | +| 2026-03-12T00:00:45.567 | 200 | 46.88 | +| 2026-03-12T00:00:55.678 | 200 | 46.89 | +| 2026-03-12T00:01:05.789 | 200 | 46.91 | +| 2026-03-12T00:01:15.890 | 200 | 46.9 | +| 2026-03-12T00:01:25.901 | 200 | 46.87 | +| 2026-03-12T00:01:35.999 | 200 | 46.85 | ++-------------------------+--------+-------+ + +select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + ++-------------------------+--------+-------+ +| ts | status | value | ++-------------------------+--------+-------+ +| 2026-03-12T00:00:05.123 | 200 | 46.82 | +| 2026-03-12T00:00:15.234 | 200 | 46.84 | +| 2026-03-12T00:00:25.345 | 200 | 46.85 | +| 2026-03-12T00:00:35.456 | 200 | 46.86 | +| 2026-03-12T00:00:45.567 | 200 | 46.88 | +| 2026-03-12T00:00:55.678 | 200 | 46.89 | +| 2026-03-12T00:01:05.789 | 200 | 46.91 | +| 2026-03-12T00:01:15.890 | 200 | 46.9 | +| 2026-03-12T00:01:25.901 | 200 | 46.87 | +| 2026-03-12T00:01:35.999 | 200 | 46.85 | ++-------------------------+--------+-------+ + +-- SQLNESS REPLACE (-+) - +-- SQLNESS REPLACE (\s\s+) _ +-- SQLNESS REPLACE (peers.*) REDACTED +-- SQLNESS REPLACE (metrics.*) REDACTED +-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED +-- SQLNESS REPLACE num_ranges=\d+ num_ranges=REDACTED +EXPLAIN ANALYZE select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + ++-+-+-+ +| stage | node | plan_| ++-+-+-+ +| 0_| 0_|_CooperativeExec REDACTED +|_|_|_MergeScanExec: REDACTED +|_|_|_| +| 1_| 0_|_ProjectionExec: expr=[to_timestamp_nanos(a_ms.ts)@0 as ts, status@1 as status, value@2 as value] REDACTED +|_|_|_SortPreservingMergeExec: [to_timestamp_nanos(a_ms.ts)@0 ASC NULLS LAST] REDACTED +|_|_|_WindowedSortExec: expr=to_timestamp_nanos(a_ms.ts)@0 ASC NULLS LAST num_ranges=REDACTED REDACTED +|_|_|_ProjectionExec: expr=[to_timestamp_nanos(ts@2) as to_timestamp_nanos(a_ms.ts), status@1 as status, value@0 as value] REDACTED +|_|_|_SeqScan: region=REDACTED, "partition_count":{"count":1, "mem_ranges":1, "files":0, "file_ranges":0} REDACTED +|_|_|_| +|_|_| Total rows: 10_| ++-+-+-+ + +DROP TABLE `a_ms`; + +Affected Rows: 0 + diff --git a/tests/cases/distributed/optimizer/windowed_sort_nanos.sql b/tests/cases/distributed/optimizer/windowed_sort_nanos.sql new file mode 100644 index 0000000000..6a6cf51c4b --- /dev/null +++ b/tests/cases/distributed/optimizer/windowed_sort_nanos.sql @@ -0,0 +1,27 @@ +create table `a_ms` (`value` double, `status` bigint, ts timestamp(3) time index); + +INSERT INTO `a_ms` (`value`, `status`, `ts`) VALUES +(46.82, 200, '2026-03-12T08:00:05.123+08:00'), +(46.84, 200, '2026-03-12T08:00:15.234+08:00'), +(46.85, 200, '2026-03-12T08:00:25.345+08:00'), +(46.86, 200, '2026-03-12T08:00:35.456+08:00'), +(46.88, 200, '2026-03-12T08:00:45.567+08:00'), +(46.89, 200, '2026-03-12T08:00:55.678+08:00'), +(46.91, 200, '2026-03-12T08:01:05.789+08:00'), +(46.90, 200, '2026-03-12T08:01:15.890+08:00'), +(46.87, 200, '2026-03-12T08:01:25.901+08:00'), +(46.85, 200, '2026-03-12T08:01:35.999+08:00'); + +select ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + +select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + +-- SQLNESS REPLACE (-+) - +-- SQLNESS REPLACE (\s\s+) _ +-- SQLNESS REPLACE (peers.*) REDACTED +-- SQLNESS REPLACE (metrics.*) REDACTED +-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED +-- SQLNESS REPLACE num_ranges=\d+ num_ranges=REDACTED +EXPLAIN ANALYZE select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + +DROP TABLE `a_ms`; diff --git a/tests/cases/standalone/optimizer/windowed_sort_nanos.result b/tests/cases/standalone/optimizer/windowed_sort_nanos.result new file mode 100644 index 0000000000..f673636307 --- /dev/null +++ b/tests/cases/standalone/optimizer/windowed_sort_nanos.result @@ -0,0 +1,78 @@ +create table `a_ms` (`value` double, `status` bigint, ts timestamp(3) time index); + +Affected Rows: 0 + +INSERT INTO `a_ms` (`value`, `status`, `ts`) VALUES +(46.82, 200, '2026-03-12T08:00:05.123+08:00'), +(46.84, 200, '2026-03-12T08:00:15.234+08:00'), +(46.85, 200, '2026-03-12T08:00:25.345+08:00'), +(46.86, 200, '2026-03-12T08:00:35.456+08:00'), +(46.88, 200, '2026-03-12T08:00:45.567+08:00'), +(46.89, 200, '2026-03-12T08:00:55.678+08:00'), +(46.91, 200, '2026-03-12T08:01:05.789+08:00'), +(46.90, 200, '2026-03-12T08:01:15.890+08:00'), +(46.87, 200, '2026-03-12T08:01:25.901+08:00'), +(46.85, 200, '2026-03-12T08:01:35.999+08:00'); + +Affected Rows: 10 + +select ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + ++-------------------------+--------+-------+ +| ts | status | value | ++-------------------------+--------+-------+ +| 2026-03-12T00:00:05.123 | 200 | 46.82 | +| 2026-03-12T00:00:15.234 | 200 | 46.84 | +| 2026-03-12T00:00:25.345 | 200 | 46.85 | +| 2026-03-12T00:00:35.456 | 200 | 46.86 | +| 2026-03-12T00:00:45.567 | 200 | 46.88 | +| 2026-03-12T00:00:55.678 | 200 | 46.89 | +| 2026-03-12T00:01:05.789 | 200 | 46.91 | +| 2026-03-12T00:01:15.890 | 200 | 46.9 | +| 2026-03-12T00:01:25.901 | 200 | 46.87 | +| 2026-03-12T00:01:35.999 | 200 | 46.85 | ++-------------------------+--------+-------+ + +select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + ++-------------------------+--------+-------+ +| ts | status | value | ++-------------------------+--------+-------+ +| 2026-03-12T00:00:05.123 | 200 | 46.82 | +| 2026-03-12T00:00:15.234 | 200 | 46.84 | +| 2026-03-12T00:00:25.345 | 200 | 46.85 | +| 2026-03-12T00:00:35.456 | 200 | 46.86 | +| 2026-03-12T00:00:45.567 | 200 | 46.88 | +| 2026-03-12T00:00:55.678 | 200 | 46.89 | +| 2026-03-12T00:01:05.789 | 200 | 46.91 | +| 2026-03-12T00:01:15.890 | 200 | 46.9 | +| 2026-03-12T00:01:25.901 | 200 | 46.87 | +| 2026-03-12T00:01:35.999 | 200 | 46.85 | ++-------------------------+--------+-------+ + +-- SQLNESS REPLACE (-+) - +-- SQLNESS REPLACE (\s\s+) _ +-- SQLNESS REPLACE (peers.*) REDACTED +-- SQLNESS REPLACE (metrics.*) REDACTED +-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED +-- SQLNESS REPLACE num_ranges=\d+ num_ranges=REDACTED +EXPLAIN ANALYZE select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + ++-+-+-+ +| stage | node | plan_| ++-+-+-+ +| 0_| 0_|_CooperativeExec REDACTED +|_|_|_MergeScanExec: REDACTED +|_|_|_| +| 1_| 0_|_SortPreservingMergeExec: [ts@0 ASC NULLS LAST] REDACTED +|_|_|_WindowedSortExec: expr=ts@0 ASC NULLS LAST num_ranges=REDACTED REDACTED +|_|_|_ProjectionExec: expr=[to_timestamp_nanos(ts@2) as ts, status@1 as status, value@0 as value] REDACTED +|_|_|_SeqScan: region=REDACTED, "partition_count":{"count":1, "mem_ranges":1, "files":0, "file_ranges":0} REDACTED +|_|_|_| +|_|_| Total rows: 10_| ++-+-+-+ + +DROP TABLE `a_ms`; + +Affected Rows: 0 + diff --git a/tests/cases/standalone/optimizer/windowed_sort_nanos.sql b/tests/cases/standalone/optimizer/windowed_sort_nanos.sql new file mode 100644 index 0000000000..6a6cf51c4b --- /dev/null +++ b/tests/cases/standalone/optimizer/windowed_sort_nanos.sql @@ -0,0 +1,27 @@ +create table `a_ms` (`value` double, `status` bigint, ts timestamp(3) time index); + +INSERT INTO `a_ms` (`value`, `status`, `ts`) VALUES +(46.82, 200, '2026-03-12T08:00:05.123+08:00'), +(46.84, 200, '2026-03-12T08:00:15.234+08:00'), +(46.85, 200, '2026-03-12T08:00:25.345+08:00'), +(46.86, 200, '2026-03-12T08:00:35.456+08:00'), +(46.88, 200, '2026-03-12T08:00:45.567+08:00'), +(46.89, 200, '2026-03-12T08:00:55.678+08:00'), +(46.91, 200, '2026-03-12T08:01:05.789+08:00'), +(46.90, 200, '2026-03-12T08:01:15.890+08:00'), +(46.87, 200, '2026-03-12T08:01:25.901+08:00'), +(46.85, 200, '2026-03-12T08:01:35.999+08:00'); + +select ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + +select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + +-- SQLNESS REPLACE (-+) - +-- SQLNESS REPLACE (\s\s+) _ +-- SQLNESS REPLACE (peers.*) REDACTED +-- SQLNESS REPLACE (metrics.*) REDACTED +-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED +-- SQLNESS REPLACE num_ranges=\d+ num_ranges=REDACTED +EXPLAIN ANALYZE select to_timestamp_nanos(ts) as ts, status, value from `a_ms` where ts >= '2026-03-12T08:00:00.000+08:00' and ts < '2026-03-12T08:02:01.000+08:00' order by ts asc; + +DROP TABLE `a_ms`;