mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 20:54:08 +00:00
* fix(operator): apply metric ingest TTL to physical tables Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * fix(operator): preserve instant TTL on logical tables and add remote write TTL hint integration test Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * fix(operator): preserve instant TTL on logical tables and add remote write TTL hint integration test Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(sqlness): regenerate logical table TTL expectation Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * refactor(operator): centralize metric logical table TTL checks Share retention-vs-instant TTL helpers between DDL validation, auto-create option filling, and ingest rejection messages so batch and SQL paths stay aligned. Signed-off-by: Tyagiquamar <Tyagiquamar@users.noreply.github.com> * fix(operator): borrow physical table name for TTL hint error Signed-off-by: Tyagiquamar <Tyagiquamar@users.noreply.github.com> * test(sqlness): expect InvalidArguments for logical retention TTL Align table_semantics with alter_table retention rejection and rustfmt the TTL hint error helper call. Signed-off-by: Tyagiquamar <Tyagiquamar@users.noreply.github.com> * feat(operator): apply retention ttl hint only on physical table creation and ignore on subsequent writes Signed-off-by: Mohd Quamar Tyagi <104281681+Tyagiquamar@users.noreply.github.com> * fix(operator): legacy logical TTL on create and restore ddl.rs LF Strip retention ttl from metric logical CREATE options with a warning so import_v2 can replay older snapshots. Narrow alter TTL checks, reduce helper visibility, and convert ddl.rs back to LF line endings. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * fix(cli): clippy in import_v2 legacy ttl test Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * docs(operator): clarify logical metric ttl alter handling Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(sqlness): add server-side coverage for legacy logical-table TTL Replace the mock import_v2 unit test with sqlness cases verifying: - SHOW CREATE TABLE omits database retention TTL on logical tables. - Legacy logical CREATE TABLE with retention TTL strips the retention option from create_options. - Explicit instant TTL remains preserved on logical tables. Group TTL_KEY import in ddl.rs and verify create_options in HTTP test. Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * refactor(operator): strip logical retention ttl in one place Every logical-table create path ends in StatementExecutor::create_logical_tables, so strip retention ttl there instead of in fill_table_options_for_create and validate_logical_create. validate_logical_create no longer mutates its input. Classify ttl by parsing it once: only a valid non-instant ttl counts as retention. Invalid values now fail normal option validation instead of being silently stripped on create or reported as retention on ALTER. Drop unit tests covered by the sqlness and HTTP integration cases. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> Signed-off-by: Tyagiquamar <Tyagiquamar@users.noreply.github.com> Signed-off-by: Mohd Quamar Tyagi <104281681+Tyagiquamar@users.noreply.github.com> Signed-off-by: Dennis Zhuang <killme2008@gmail.com> Co-authored-by: Tyagiquamar <Tyagiquamar@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Dennis Zhuang <killme2008@gmail.com>
376 lines
18 KiB
Plaintext
376 lines
18 KiB
Plaintext
DESC TABLE information_schema.table_semantics;
|
|
|
|
+---------------------+--------+-----+------+---------+---------------+
|
|
| Column | Type | Key | Null | Default | Semantic Type |
|
|
+---------------------+--------+-----+------+---------+---------------+
|
|
| table_catalog | String | | NO | | FIELD |
|
|
| table_schema | String | | NO | | FIELD |
|
|
| table_name | String | | NO | | FIELD |
|
|
| table_id | UInt32 | | NO | | FIELD |
|
|
| signal_type | String | | YES | | FIELD |
|
|
| source | String | | YES | | FIELD |
|
|
| source_version | String | | YES | | FIELD |
|
|
| pipeline | String | | YES | | FIELD |
|
|
| metadata_quality | String | | YES | | FIELD |
|
|
| semantic_options | String | | YES | | FIELD |
|
|
| entity_declarations | String | | YES | | FIELD |
|
|
+---------------------+--------+-----+------+---------+---------------+
|
|
|
|
CREATE TABLE metrics_tagged (
|
|
ts TIMESTAMP TIME INDEX,
|
|
val DOUBLE,
|
|
)
|
|
WITH (
|
|
'greptime.semantic.signal_type' = 'metric',
|
|
'greptime.semantic.source' = 'opentelemetry',
|
|
'greptime.semantic.source_version' = '2.0',
|
|
'greptime.semantic.pipeline' = 'greptime_metric_v1',
|
|
'greptime.semantic.metric.metadata_quality' = 'declared',
|
|
'greptime.semantic.metric.type' = 'counter',
|
|
'greptime.semantic.metric.unit' = 'By'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE traces_tagged (
|
|
ts TIMESTAMP TIME INDEX,
|
|
span_name STRING,
|
|
)
|
|
WITH (
|
|
'greptime.semantic.signal_type' = 'trace',
|
|
'greptime.semantic.source' = 'opentelemetry',
|
|
'greptime.semantic.trace.conventions' = 'https://opentelemetry.io/schemas/1.27.0'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
-- A table with no semantic options must not appear in the view.
|
|
CREATE TABLE plain_table (
|
|
ts TIMESTAMP TIME INDEX,
|
|
val DOUBLE,
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_schema, table_name, signal_type, source, source_version, pipeline, metadata_quality, semantic_options
|
|
FROM information_schema.table_semantics
|
|
WHERE table_schema = 'public'
|
|
ORDER BY table_name;
|
|
|
|
+--------------+----------------+-------------+---------------+----------------+--------------------+------------------+-----------------------------------------------------------------+
|
|
| table_schema | table_name | signal_type | source | source_version | pipeline | metadata_quality | semantic_options |
|
|
+--------------+----------------+-------------+---------------+----------------+--------------------+------------------+-----------------------------------------------------------------+
|
|
| public | metrics_tagged | metric | opentelemetry | 2.0 | greptime_metric_v1 | declared | {"metric.type":"counter","metric.unit":"By"} |
|
|
| public | traces_tagged | trace | opentelemetry | | | | {"trace.conventions":"https://opentelemetry.io/schemas/1.27.0"} |
|
|
+--------------+----------------+-------------+---------------+----------------+--------------------+------------------+-----------------------------------------------------------------+
|
|
|
|
-- System table scope is exposed without changing the view's columns.
|
|
SELECT table_name, semantic_options
|
|
FROM information_schema.table_semantics
|
|
WHERE table_schema = 'information_schema'
|
|
AND table_name IN ('build_info', 'engines', 'character_sets', 'collations',
|
|
'collation_character_set_applicability', 'partitions',
|
|
'process_list', 'table_semantics')
|
|
ORDER BY table_name;
|
|
|
|
+---------------------------------------+---------------------------------+
|
|
| table_name | semantic_options |
|
|
+---------------------------------------+---------------------------------+
|
|
| build_info | {"table_scope":"public_global"} |
|
|
| character_sets | {"table_scope":"public_global"} |
|
|
| collation_character_set_applicability | {"table_scope":"public_global"} |
|
|
| collations | {"table_scope":"public_global"} |
|
|
| engines | {"table_scope":"public_global"} |
|
|
| partitions | {"table_scope":"catalog"} |
|
|
| process_list | {"table_scope":"global"} |
|
|
| table_semantics | {"table_scope":"catalog"} |
|
|
+---------------------------------------+---------------------------------+
|
|
|
|
-- Predicate pushdown on a promoted column.
|
|
SELECT table_name, signal_type
|
|
FROM information_schema.table_semantics
|
|
WHERE signal_type = 'metric'
|
|
ORDER BY table_name;
|
|
|
|
+----------------+-------------+
|
|
| table_name | signal_type |
|
|
+----------------+-------------+
|
|
| metrics_tagged | metric |
|
|
+----------------+-------------+
|
|
|
|
DROP TABLE metrics_tagged;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE traces_tagged;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE plain_table;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- ALTER TABLE manages semantic declarations on existing tables: SET appears in
|
|
-- the view, UNSET disappears from it.
|
|
CREATE TABLE altered_semantics (
|
|
ts TIMESTAMP TIME INDEX,
|
|
svc STRING,
|
|
payload BINARY,
|
|
val DOUBLE,
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
ALTER TABLE altered_semantics SET 'greptime.semantic.signal_type' = 'metric', 'greptime.semantic.entity.service.id' = 'svc';
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, signal_type, semantic_options
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'altered_semantics';
|
|
|
|
+-------------------+-------------+-----------------------------+
|
|
| table_name | signal_type | semantic_options |
|
|
+-------------------+-------------+-----------------------------+
|
|
| altered_semantics | metric | {"entity.service.id":"svc"} |
|
|
+-------------------+-------------+-----------------------------+
|
|
|
|
-- Semantic options never share a statement with regular table options.
|
|
ALTER TABLE altered_semantics SET 'greptime.semantic.source' = 'prometheus', 'ttl' = '7d';
|
|
|
|
Error: 1004(InvalidArguments), Invalid table option request: `greptime.semantic.*` options must be altered separately from other table options
|
|
|
|
-- Unknown semantic keys are rejected on SET.
|
|
ALTER TABLE altered_semantics SET 'greptime.semantic.nonsense' = 'x';
|
|
|
|
Error: 1004(InvalidArguments), Invalid alter table(altered_semantics) request: unknown semantic option `greptime.semantic.nonsense`
|
|
|
|
-- Values outside the key's domain are rejected.
|
|
ALTER TABLE altered_semantics SET 'greptime.semantic.signal_type' = 'garbage';
|
|
|
|
Error: 1004(InvalidArguments), Invalid alter table(altered_semantics) request: invalid value `garbage` for semantic option `greptime.semantic.signal_type`
|
|
|
|
-- Entity columns must exist.
|
|
ALTER TABLE altered_semantics SET 'greptime.semantic.entity.host.id' = 'no_such_column';
|
|
|
|
Error: 4002(TableColumnNotFound), Column no_such_column not exists in table altered_semantics
|
|
|
|
-- Entity columns must render as strings.
|
|
ALTER TABLE altered_semantics SET 'greptime.semantic.entity.host.id' = 'payload';
|
|
|
|
Error: 1004(InvalidArguments), Invalid alter table(altered_semantics) request: entity column `payload` (option `greptime.semantic.entity.host.id`) has type `Binary`, which cannot render as a string
|
|
|
|
ALTER TABLE altered_semantics UNSET 'greptime.semantic.entity.service.id';
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, signal_type, semantic_options
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'altered_semantics';
|
|
|
|
+-------------------+-------------+------------------+
|
|
| table_name | signal_type | semantic_options |
|
|
+-------------------+-------------+------------------+
|
|
| altered_semantics | metric | |
|
|
+-------------------+-------------+------------------+
|
|
|
|
DROP TABLE altered_semantics;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- Logical metric tables take the same metadata-only path.
|
|
CREATE TABLE phy_sem (ts TIMESTAMP TIME INDEX, val DOUBLE) engine=metric with ("physical_metric_table" = "");
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE logical_sem (ts TIMESTAMP TIME INDEX, val DOUBLE, host STRING PRIMARY KEY) engine=metric with ("on_physical_table" = "phy_sem");
|
|
|
|
Affected Rows: 0
|
|
|
|
ALTER TABLE logical_sem SET 'greptime.semantic.signal_type' = 'metric', 'greptime.semantic.entity.host.id' = 'host';
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, signal_type, semantic_options
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'logical_sem';
|
|
|
|
+-------------+-------------+---------------------------+
|
|
| table_name | signal_type | semantic_options |
|
|
+-------------+-------------+---------------------------+
|
|
| logical_sem | metric | {"entity.host.id":"host"} |
|
|
+-------------+-------------+---------------------------+
|
|
|
|
-- Regular options still cannot be altered on logical tables.
|
|
ALTER TABLE logical_sem SET 'ttl' = '7d';
|
|
|
|
Error: 1004(InvalidArguments), Retention TTL is not supported on metric logical tables; set `ttl` on the physical table instead
|
|
|
|
ALTER TABLE logical_sem UNSET 'greptime.semantic.entity.host.id';
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, signal_type, semantic_options
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'logical_sem';
|
|
|
|
+-------------+-------------+------------------+
|
|
| table_name | signal_type | semantic_options |
|
|
+-------------+-------------+------------------+
|
|
| logical_sem | metric | |
|
|
+-------------+-------------+------------------+
|
|
|
|
DROP TABLE logical_sem;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE phy_sem;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- entity_declarations reports what a table actually contributes to the graph,
|
|
-- including the declarations the built-in conventions derive. A whitelisted
|
|
-- OTel descriptor table declares its entities without any entity option, and
|
|
-- the generic container records the identity it yields to.
|
|
CREATE TABLE greptime_otel_resource_info (
|
|
greptime_timestamp TIMESTAMP TIME INDEX,
|
|
greptime_value DOUBLE,
|
|
"job" STRING,
|
|
"instance" STRING,
|
|
"service.name" STRING,
|
|
"host.id" STRING,
|
|
"container.id" STRING,
|
|
"container.name" STRING,
|
|
"k8s.pod.uid" STRING,
|
|
"k8s.pod.name" STRING,
|
|
"k8s.container.name" STRING,
|
|
PRIMARY KEY ("job", "instance", "service.name", "host.id", "container.id", "container.name", "k8s.pod.uid", "k8s.pod.name", "k8s.container.name")
|
|
)
|
|
WITH (
|
|
'greptime.semantic.signal_type' = 'metric',
|
|
'greptime.semantic.source' = 'opentelemetry',
|
|
'greptime.semantic.metric.type' = 'info'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, entity_declarations
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'greptime_otel_resource_info';
|
|
|
|
+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| table_name | entity_declarations |
|
|
+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| greptime_otel_resource_info | [{"entity_type":"container","origin":"convention","id":["container.id"],"superseded_by":["k8s.pod.uid","k8s.container.name"],"descriptive":["container.name"]},{"entity_type":"host","origin":"convention","id":["host.id"]},{"entity_type":"k8s.container","origin":"convention","id":["k8s.pod.uid","k8s.container.name"],"descriptive":["container.id","container.name"]},{"entity_type":"k8s.pod","origin":"convention","id":["k8s.pod.uid"],"descriptive":["k8s.pod.name"]},{"entity_type":"service","origin":"convention","id":["job"],"descriptive":["service.name"]},{"entity_type":"service.instance","origin":"convention","id":["job","instance"]}] |
|
|
+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-- The same table under the wrong source stamp derives nothing: the column is
|
|
-- empty and `source` names the reason.
|
|
CREATE TABLE kube_pod_info (
|
|
greptime_timestamp TIMESTAMP TIME INDEX,
|
|
greptime_value DOUBLE,
|
|
"namespace" STRING,
|
|
"pod" STRING,
|
|
"uid" STRING,
|
|
"node" STRING,
|
|
PRIMARY KEY ("namespace", "pod", "uid", "node")
|
|
)
|
|
WITH (
|
|
'greptime.semantic.signal_type' = 'metric',
|
|
'greptime.semantic.source' = 'influxdb'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, source, entity_declarations
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'kube_pod_info';
|
|
|
|
+---------------+----------+---------------------+
|
|
| table_name | source | entity_declarations |
|
|
+---------------+----------+---------------------+
|
|
| kube_pod_info | influxdb | |
|
|
+---------------+----------+---------------------+
|
|
|
|
ALTER TABLE kube_pod_info SET 'greptime.semantic.source' = 'prometheus';
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, source, entity_declarations
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'kube_pod_info';
|
|
|
|
+---------------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| table_name | source | entity_declarations |
|
|
+---------------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| kube_pod_info | prometheus | [{"entity_type":"k8s.node","origin":"convention","id":["node"]},{"entity_type":"k8s.pod","origin":"convention","id":["uid"],"descriptive":["namespace","pod","node"]}] |
|
|
+---------------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
DROP TABLE greptime_otel_resource_info;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE kube_pod_info;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- A missing id column drops that entity alone: without `uid` there is no
|
|
-- k8s.pod, and the k8s.node next to it still lands.
|
|
CREATE TABLE kube_pod_info (
|
|
greptime_timestamp TIMESTAMP TIME INDEX,
|
|
greptime_value DOUBLE,
|
|
"namespace" STRING,
|
|
"pod" STRING,
|
|
"node" STRING,
|
|
PRIMARY KEY ("namespace", "pod", "node")
|
|
)
|
|
WITH (
|
|
'greptime.semantic.signal_type' = 'metric',
|
|
'greptime.semantic.source' = 'prometheus'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, entity_declarations
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'kube_pod_info';
|
|
|
|
+---------------+------------------------------------------------------------------+
|
|
| table_name | entity_declarations |
|
|
+---------------+------------------------------------------------------------------+
|
|
| kube_pod_info | [{"entity_type":"k8s.node","origin":"convention","id":["node"]}] |
|
|
+---------------+------------------------------------------------------------------+
|
|
|
|
DROP TABLE kube_pod_info;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- A trace table carries no semantic option at all, yet the conventions derive
|
|
-- its entities: it must still be visible here, or the view cannot answer why
|
|
-- it is in the graph.
|
|
CREATE TABLE traces_untagged (
|
|
"timestamp" TIMESTAMP(9) TIME INDEX,
|
|
trace_id STRING,
|
|
span_id STRING,
|
|
service_name STRING,
|
|
"resource_attributes.host.id" STRING,
|
|
PRIMARY KEY (service_name)
|
|
) WITH ('table_data_model' = 'greptime_trace_v1', 'append_mode' = 'true');
|
|
|
|
Affected Rows: 0
|
|
|
|
SELECT table_name, signal_type, semantic_options, entity_declarations
|
|
FROM information_schema.table_semantics
|
|
WHERE table_name = 'traces_untagged';
|
|
|
|
+-----------------+-------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| table_name | signal_type | semantic_options | entity_declarations |
|
|
+-----------------+-------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| traces_untagged | | | [{"entity_type":"host","origin":"convention","id":["resource_attributes.host.id"]},{"entity_type":"service","origin":"convention","id":["service_name"]}] |
|
|
+-----------------+-------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
DROP TABLE traces_untagged;
|
|
|
|
Affected Rows: 0
|
|
|