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!
pull/24376/head
Carol (Nichols || Goulding) 2022-11-07 13:36:00 -05:00
parent 9b0af96927
commit 74a40cc9bd
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
2 changed files with 18 additions and 3 deletions

View File

@ -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
);
}
}
}

View File

@ -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"
);
}
}
}