mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 20:54:08 +00:00
* feat(partition): support iceberg_hash in partition rules Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(partition): reject partition column type changes and quote rule identifiers Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(table): keep time index widening for partition columns Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(partition): replace PartitionFunction with IcebergHash Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(partition): describe iceberg_hash in the function module Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(meta): validate iceberg_hash partition bounds on ALTER and trim comments Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test: quote partition rule identifiers in SHOW CREATE TABLE expectations Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(partition): check hash rules in information_schema and repartition target columns Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(partition): coerce hash partition rules against the evaluation schema Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(partition): keep quotes in partition column names when building filters Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
80 lines
4.3 KiB
Plaintext
80 lines
4.3 KiB
Plaintext
SHOW CREATE TABLE iceberg_hash_routes;
|
|
|
|
+---------------------+-------------------------------------------------------------+
|
|
| Table | Create Table |
|
|
+---------------------+-------------------------------------------------------------+
|
|
| iceberg_hash_routes | CREATE TABLE IF NOT EXISTS "iceberg_hash_routes" ( |
|
|
| | "host" STRING NULL, |
|
|
| | "tenant" BIGINT UNSIGNED NULL, |
|
|
| | "ts" TIMESTAMP(3) NOT NULL, |
|
|
| | "v" INT NULL, |
|
|
| | TIME INDEX ("ts"), |
|
|
| | PRIMARY KEY ("host", "tenant") |
|
|
| | ) |
|
|
| | PARTITION ON COLUMNS ("host", "tenant") ( |
|
|
| | iceberg_hash("host") < 0 AND "tenant" < 100, |
|
|
| | iceberg_hash("host") < 0 AND "tenant" >= 100, |
|
|
| | iceberg_hash("host") >= 0 AND iceberg_hash("tenant") < 0, |
|
|
| | iceberg_hash("host") >= 0 AND iceberg_hash("tenant") >= 0 |
|
|
| | ) |
|
|
| | ENGINE=mito |
|
|
| | |
|
|
+---------------------+-------------------------------------------------------------+
|
|
|
|
SELECT * FROM iceberg_hash_routes ORDER BY ts;
|
|
|
|
+----------+----------------------+-------------------------+---+
|
|
| host | tenant | ts | v |
|
|
+----------+----------------------+-------------------------+---+
|
|
| a | 1 | 1970-01-01T00:00:00.001 | 1 |
|
|
| b | 100 | 1970-01-01T00:00:00.002 | 2 |
|
|
| server42 | 18446744073709551615 | 1970-01-01T00:00:00.003 | 3 |
|
|
| 中🙂 | 0 | 1970-01-01T00:00:00.004 | 4 |
|
|
| | 7 | 1970-01-01T00:00:00.005 | 5 |
|
|
+----------+----------------------+-------------------------+---+
|
|
|
|
-- Overwrites must route to the regions holding the flushed rows.
|
|
INSERT INTO iceberg_hash_routes VALUES
|
|
('a', 1, 1, 10),
|
|
('b', 100, 2, 20),
|
|
('server42', 18446744073709551615, 3, 30),
|
|
('中🙂', 0, 4, 40),
|
|
(NULL, 7, 5, 50);
|
|
|
|
Affected Rows: 5
|
|
|
|
SELECT * FROM iceberg_hash_routes ORDER BY ts;
|
|
|
|
+----------+----------------------+-------------------------+----+
|
|
| host | tenant | ts | v |
|
|
+----------+----------------------+-------------------------+----+
|
|
| a | 1 | 1970-01-01T00:00:00.001 | 10 |
|
|
| b | 100 | 1970-01-01T00:00:00.002 | 20 |
|
|
| server42 | 18446744073709551615 | 1970-01-01T00:00:00.003 | 30 |
|
|
| 中🙂 | 0 | 1970-01-01T00:00:00.004 | 40 |
|
|
| | 7 | 1970-01-01T00:00:00.005 | 50 |
|
|
+----------+----------------------+-------------------------+----+
|
|
|
|
SELECT * FROM iceberg_hash_routes WHERE host = 'server42';
|
|
|
|
+----------+----------------------+-------------------------+----+
|
|
| host | tenant | ts | v |
|
|
+----------+----------------------+-------------------------+----+
|
|
| server42 | 18446744073709551615 | 1970-01-01T00:00:00.003 | 30 |
|
|
+----------+----------------------+-------------------------+----+
|
|
|
|
DELETE FROM iceberg_hash_routes WHERE host = 'b';
|
|
|
|
Affected Rows: 1
|
|
|
|
SELECT * FROM iceberg_hash_routes ORDER BY ts;
|
|
|
|
+----------+----------------------+-------------------------+----+
|
|
| host | tenant | ts | v |
|
|
+----------+----------------------+-------------------------+----+
|
|
| a | 1 | 1970-01-01T00:00:00.001 | 10 |
|
|
| server42 | 18446744073709551615 | 1970-01-01T00:00:00.003 | 30 |
|
|
| 中🙂 | 0 | 1970-01-01T00:00:00.004 | 40 |
|
|
| | 7 | 1970-01-01T00:00:00.005 | 50 |
|
|
+----------+----------------------+-------------------------+----+
|