fix!: disable append mode in trace services table (#6066)

fix: disable append mode in trace services table and make 'service_name' as primary key
This commit is contained in:
zyy17
2025-05-10 03:06:51 +08:00
committed by GitHub
parent 8dca448baf
commit 50df275097
3 changed files with 7 additions and 3 deletions

View File

@@ -580,6 +580,10 @@ impl Inserter {
// for it's a very unexpected behavior and should be set by user explicitly
for mut create_table in create_tables {
if create_table.table_name == trace_services_table_name(trace_table_name) {
// Disable append mode for trace services table since it requires upsert behavior.
create_table
.table_options
.insert(APPEND_MODE_KEY.to_string(), "false".to_string());
let table = self
.create_physical_table(create_table, None, ctx, statement_executor)
.await?;

View File

@@ -176,9 +176,9 @@ fn write_trace_services_to_row(writer: &mut TableData, services: HashSet<String>
)?;
// Write the `service_name` column.
row_writer::write_fields(
row_writer::write_tags(
writer,
std::iter::once(make_string_column_data(SERVICE_NAME_COLUMN, service_name)),
std::iter::once((SERVICE_NAME_COLUMN.to_string(), service_name)),
&mut row,
)?;
writer.add_row(row);

View File

@@ -2838,7 +2838,7 @@ pub async fn test_otlp_traces_v1(store_type: StorageType) {
)
.await;
let expected_ddl = r#"[["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)\n\nENGINE=mito\nWITH(\n append_mode = 'true'\n)"]]"#;
let expected_ddl = r#"[["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(
"otlp_traces",
&client,