mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-23 12:22:35 +00:00
On append-mode tables a region reports an exact row count. When it is zero, DataFusion's AggregateStatistics replaces the region-side __min_state/__max_state aggregate with a non-null struct literal, so the remote stream advertises the state column as non-nullable. The MergeScan schema check required equal nullability and failed the query. Accept a remote field that is non-nullable where the expected field is nullable, matching DataFusion's own physical-plan schema invariant. Batches are already rebuilt with the expected schema. Widening is still rejected, and nested field nullability is still compared exactly as part of the data type. Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
43 lines
1.1 KiB
SQL
43 lines
1.1 KiB
SQL
-- Append-mode regions report exact row counts, so the datanode can answer
|
|
-- count/min/max over a region from statistics. This only happens when every
|
|
-- aggregate in the query can be answered that way.
|
|
CREATE TABLE a1 (ts TIMESTAMP(9) TIME INDEX, k STRING, v BIGINT)
|
|
PARTITION ON COLUMNS (k) (k < 'b', k >= 'b' AND k < 'c', k >= 'c')
|
|
WITH (append_mode = 'true');
|
|
|
|
-- All regions are empty.
|
|
SELECT min(v), max(v) FROM a1;
|
|
|
|
SELECT count(*), count(v) FROM a1;
|
|
|
|
INSERT INTO a1 VALUES (1000, 'a', 1), (2000, 'a', 2);
|
|
|
|
-- Two of three regions are empty.
|
|
SELECT min(v) FROM a1;
|
|
|
|
SELECT max(v) FROM a1;
|
|
|
|
SELECT min(ts), max(k) FROM a1;
|
|
|
|
SELECT count(*), count(v) FROM a1;
|
|
|
|
SELECT min(v), count(*) FROM a1;
|
|
|
|
SELECT sum(v), avg(v) FROM a1;
|
|
|
|
SELECT k, min(v), max(v), count(*) FROM a1 GROUP BY k ORDER BY k;
|
|
|
|
INSERT INTO a1 VALUES (3000, 'b', 3);
|
|
|
|
-- One of three regions is empty.
|
|
SELECT min(v), max(v) FROM a1;
|
|
|
|
SELECT k, min(v), max(v), count(*) FROM a1 GROUP BY k ORDER BY k;
|
|
|
|
INSERT INTO a1 VALUES (4000, 'c', 4);
|
|
|
|
-- No region is empty.
|
|
SELECT min(v), max(v), count(*) FROM a1;
|
|
|
|
DROP TABLE a1;
|