fix: remap column indices on overriding logical table partitions (#6446)

* fix: remap column indices on overriding logical table partitions

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* sqlness

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* refactor map query

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2025-07-02 12:12:00 +00:00
committed by GitHub
parent b1b0d0136f
commit 5f2daae087
3 changed files with 42 additions and 39 deletions
@@ -1,9 +1,12 @@
create table metric_engine_partition (
ts timestamp time index,
host string primary key,
host string,
cpu double,
`one_partition_key` string,
`another_partition_key` string,
primary key(host, `one_partition_key`, `another_partition_key`)
)
partition on columns (host) (
partition on columns (host, `one_partition_key`, `another_partition_key`) (
host <= 'host1',
host > 'host1' and host <= 'host2',
host > 'host2'
@@ -64,26 +67,26 @@ Affected Rows: 0
show create table logical_table_2;
+-----------------+-------------------------------------------------+
| Table | Create Table |
+-----------------+-------------------------------------------------+
| logical_table_2 | CREATE TABLE IF NOT EXISTS "logical_table_2" ( |
| | "cpu" DOUBLE NULL, |
| | "host" STRING NULL, |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | TIME INDEX ("ts"), |
| | PRIMARY KEY ("host") |
| | ) |
| | PARTITION ON COLUMNS ("host") ( |
| | host <= 'host1', |
| | host > 'host2', |
| | host > 'host1' AND host <= 'host2' |
| | ) |
| | ENGINE=metric |
| | WITH( |
| | on_physical_table = 'metric_engine_partition' |
| | ) |
+-----------------+-------------------------------------------------+
+-----------------+-------------------------------------------------------------------------------+
| Table | Create Table |
+-----------------+-------------------------------------------------------------------------------+
| logical_table_2 | CREATE TABLE IF NOT EXISTS "logical_table_2" ( |
| | "cpu" DOUBLE NULL, |
| | "host" STRING NULL, |
| | "ts" TIMESTAMP(3) NOT NULL, |
| | TIME INDEX ("ts"), |
| | PRIMARY KEY ("host") |
| | ) |
| | PARTITION ON COLUMNS ("host", "one_partition_key", "another_partition_key") ( |
| | host <= 'host1', |
| | host > 'host2', |
| | host > 'host1' AND host <= 'host2' |
| | ) |
| | ENGINE=metric |
| | WITH( |
| | on_physical_table = 'metric_engine_partition' |
| | ) |
+-----------------+-------------------------------------------------------------------------------+
select count(*) from logical_table_2;
@@ -1,9 +1,12 @@
create table metric_engine_partition (
ts timestamp time index,
host string primary key,
host string,
cpu double,
`one_partition_key` string,
`another_partition_key` string,
primary key(host, `one_partition_key`, `another_partition_key`)
)
partition on columns (host) (
partition on columns (host, `one_partition_key`, `another_partition_key`) (
host <= 'host1',
host > 'host1' and host <= 'host2',
host > 'host2'