Files
greptimedb/tests/cases/standalone/common/create/metric_engine_partition.sql
Ruihang Xia 5f2daae087 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>
2025-07-02 12:12:00 +00:00

63 lines
1.3 KiB
SQL

create table metric_engine_partition (
ts timestamp time index,
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, `one_partition_key`, `another_partition_key`) (
host <= 'host1',
host > 'host1' and host <= 'host2',
host > 'host2'
)
engine = metric
with (
physical_metric_table = "true",
);
select count(*) from metric_engine_partition;
create table logical_table_1 (
ts timestamp time index,
host string primary key,
cpu double,
)
partition on columns (host) ()
engine = metric
with (
on_physical_table = "metric_engine_partition",
);
create table logical_table_2 (
ts timestamp time index,
host string primary key,
cpu double,
)
engine = metric
with (
on_physical_table = "metric_engine_partition",
);
create table logical_table_3 (
ts timestamp time index,
a string,
z string,
cpu double,
primary key(a, z) -- trigger a physical table change with smaller and bigger column ids
)
engine = metric
with (
on_physical_table = "metric_engine_partition",
);
show create table logical_table_2;
select count(*) from logical_table_2;
drop table logical_table_2;
drop table logical_table_3;
drop table metric_engine_partition;