From a3dbd029c5fefd347222814ec2b6aafb66c58bb9 Mon Sep 17 00:00:00 2001 From: shuiyisong <113876041+shuiyisong@users.noreply.github.com> Date: Thu, 6 Nov 2025 19:51:45 +0800 Subject: [PATCH] chore: remove ttl option if presents in trace meta table (#7197) * chore: remove ttl option if presents in trace meta table Signed-off-by: shuiyisong * chore: update test Signed-off-by: shuiyisong --------- Signed-off-by: shuiyisong --- src/operator/src/insert.rs | 6 +++++- tests-integration/tests/http.rs | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/operator/src/insert.rs b/src/operator/src/insert.rs index 9de4fb3fba..c323677f43 100644 --- a/src/operator/src/insert.rs +++ b/src/operator/src/insert.rs @@ -54,7 +54,8 @@ use store_api::metric_engine_consts::{ LOGICAL_TABLE_METADATA_KEY, METRIC_ENGINE_NAME, PHYSICAL_TABLE_METADATA_KEY, }; use store_api::mito_engine_options::{ - APPEND_MODE_KEY, COMPACTION_TYPE, COMPACTION_TYPE_TWCS, MERGE_MODE_KEY, TWCS_TIME_WINDOW, + APPEND_MODE_KEY, COMPACTION_TYPE, COMPACTION_TYPE_TWCS, MERGE_MODE_KEY, TTL_KEY, + TWCS_TIME_WINDOW, }; use store_api::storage::{RegionId, TableId}; use table::TableRef; @@ -626,6 +627,9 @@ impl Inserter { create_table .table_options .insert(APPEND_MODE_KEY.to_string(), "false".to_string()); + // Remove `ttl` key from table options if it exists + create_table.table_options.remove(TTL_KEY); + let table = self .create_physical_table(create_table, None, ctx, statement_executor) .await?; diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index 62275b79f4..b4d437cd99 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -6072,6 +6072,10 @@ pub async fn test_jaeger_query_api_for_trace_v1(store_type: StorageType) { HeaderName::from_static("x-greptime-log-pipeline-name"), HeaderValue::from_static(GREPTIME_INTERNAL_TRACE_PIPELINE_V1_NAME), ), + ( + HeaderName::from_static("x-greptime-hints"), + HeaderValue::from_static("ttl=7d"), + ), ( HeaderName::from_static("x-greptime-trace-table-name"), HeaderValue::from_static(trace_table_name), @@ -6084,6 +6088,24 @@ pub async fn test_jaeger_query_api_for_trace_v1(store_type: StorageType) { .await; assert_eq!(StatusCode::OK, res.status()); + let trace_table_sql = "[[\"mytable\",\"CREATE TABLE IF NOT EXISTS \\\"mytable\\\" (\\n \\\"timestamp\\\" TIMESTAMP(9) NOT NULL,\\n \\\"timestamp_end\\\" TIMESTAMP(9) NULL,\\n \\\"duration_nano\\\" BIGINT UNSIGNED NULL,\\n \\\"parent_span_id\\\" STRING NULL SKIPPING INDEX WITH(false_positive_rate = '0.01', granularity = '10240', type = 'BLOOM'),\\n \\\"trace_id\\\" STRING NULL SKIPPING INDEX WITH(false_positive_rate = '0.01', granularity = '10240', type = 'BLOOM'),\\n \\\"span_id\\\" STRING NULL,\\n \\\"span_kind\\\" STRING NULL,\\n \\\"span_name\\\" STRING NULL,\\n \\\"span_status_code\\\" STRING NULL,\\n \\\"span_status_message\\\" STRING NULL,\\n \\\"trace_state\\\" STRING NULL,\\n \\\"scope_name\\\" STRING NULL,\\n \\\"scope_version\\\" STRING NULL,\\n \\\"service_name\\\" STRING NULL SKIPPING INDEX WITH(false_positive_rate = '0.01', granularity = '10240', type = 'BLOOM'),\\n \\\"span_attributes.operation.type\\\" STRING NULL,\\n \\\"span_attributes.net.peer.ip\\\" STRING NULL,\\n \\\"span_attributes.peer.service\\\" STRING NULL,\\n \\\"span_events\\\" JSON NULL,\\n \\\"span_links\\\" JSON NULL,\\n TIME INDEX (\\\"timestamp\\\"),\\n PRIMARY KEY (\\\"service_name\\\")\\n)\\nPARTITION ON COLUMNS (\\\"trace_id\\\") (\\n trace_id < '1',\\n trace_id >= '1' AND trace_id < '2',\\n trace_id >= '2' AND trace_id < '3',\\n trace_id >= '3' AND trace_id < '4',\\n trace_id >= '4' AND trace_id < '5',\\n trace_id >= '5' AND trace_id < '6',\\n trace_id >= '6' AND trace_id < '7',\\n trace_id >= '7' AND trace_id < '8',\\n trace_id >= '8' AND trace_id < '9',\\n trace_id >= '9' AND trace_id < 'a',\\n trace_id >= 'a' AND trace_id < 'b',\\n trace_id >= 'b' AND trace_id < 'c',\\n trace_id >= 'c' AND trace_id < 'd',\\n trace_id >= 'd' AND trace_id < 'e',\\n trace_id >= 'e' AND trace_id < 'f',\\n trace_id >= 'f'\\n)\\nENGINE=mito\\nWITH(\\n append_mode = 'true',\\n table_data_model = 'greptime_trace_v1',\\n ttl = '7days'\\n)\"]]"; + validate_data( + "trace_v1_create_table", + &client, + "show create table mytable;", + trace_table_sql, + ) + .await; + + let trace_meta_table_sql = "[[\"mytable_services\",\"CREATE TABLE IF NOT EXISTS \\\"mytable_services\\\" (\\n \\\"timestamp\\\" TIMESTAMP(9) NOT NULL,\\n \\\"service_name\\\" STRING NULL,\\n TIME INDEX (\\\"timestamp\\\"),\\n PRIMARY KEY (\\\"service_name\\\")\\n)\\n\\nENGINE=mito\\nWITH(\\n append_mode = 'false'\\n)\"]]"; + validate_data( + "trace_v1_create_meta_table", + &client, + "show create table mytable_services;", + trace_meta_table_sql, + ) + .await; + // Test `/api/services` API. let res = client .get("/v1/jaeger/api/services")