From 74a40cc9bdf62b422c9fa4fac60232f2d74a710f Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 7 Nov 2022 13:36:00 -0500 Subject: [PATCH] fix: Assert that there aren't two columns with the same name in the same batch This shouldn't be possible; let's make sure we know if it happens! --- import/src/aggregate_tsm_schema/update_catalog.rs | 15 +++++++++++++-- iox_catalog/src/lib.rs | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/import/src/aggregate_tsm_schema/update_catalog.rs b/import/src/aggregate_tsm_schema/update_catalog.rs index c944a4544f..18c7496a97 100644 --- a/import/src/aggregate_tsm_schema/update_catalog.rs +++ b/import/src/aggregate_tsm_schema/update_catalog.rs @@ -218,7 +218,12 @@ where } None => { // column doesn't exist; add it - column_batch.insert(tag.name.as_str(), ColumnType::Tag); + let old = column_batch.insert(tag.name.as_str(), ColumnType::Tag); + assert!( + old.is_none(), + "duplicate column name `{}` in new column batch shouldn't be possible", + tag.name + ); } } } @@ -251,7 +256,13 @@ where } None => { // column doesn't exist; add it - column_batch.insert(field.name.as_str(), ColumnType::from(influx_column_type)); + let old = column_batch + .insert(field.name.as_str(), ColumnType::from(influx_column_type)); + assert!( + old.is_none(), + "duplicate column name `{}` in new column batch shouldn't be possible", + field.name + ); } } } diff --git a/iox_catalog/src/lib.rs b/iox_catalog/src/lib.rs index 51aaa54ac3..da7a409122 100644 --- a/iox_catalog/src/lib.rs +++ b/iox_catalog/src/lib.rs @@ -176,7 +176,11 @@ where None => { // The column does not exist in the cache, add it to the column // batch to be bulk inserted later. - column_batch.insert(name.as_str(), ColumnType::from(col.influx_type())); + let old = column_batch.insert(name.as_str(), ColumnType::from(col.influx_type())); + assert!( + old.is_none(), + "duplicate column name `{name}` in new column batch shouldn't be possible" + ); } } }