mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 22:32:55 +00:00
chore: improve error message when there are more than one time index (#6796)
* chore: improve error message when there are more than one time index Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: style Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -12376,6 +12376,7 @@ dependencies = [
|
||||
"derive_builder 0.20.2",
|
||||
"futures",
|
||||
"humantime",
|
||||
"itertools 0.14.0",
|
||||
"lazy_static",
|
||||
"num_enum 0.7.4",
|
||||
"prometheus",
|
||||
|
||||
@@ -25,6 +25,7 @@ datatypes.workspace = true
|
||||
derive_builder.workspace = true
|
||||
futures.workspace = true
|
||||
humantime.workspace = true
|
||||
itertools.workspace = true
|
||||
lazy_static.workspace = true
|
||||
num_enum = "0.7"
|
||||
prometheus.workspace = true
|
||||
|
||||
@@ -31,6 +31,7 @@ use datatypes::arrow;
|
||||
use datatypes::arrow::datatypes::FieldRef;
|
||||
use datatypes::schema::{ColumnSchema, FulltextOptions, Schema, SchemaRef};
|
||||
use datatypes::types::TimestampType;
|
||||
use itertools::Itertools;
|
||||
use serde::de::Error;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use snafu::{ensure, Location, OptionExt, ResultExt, Snafu};
|
||||
@@ -406,15 +407,22 @@ impl RegionMetadata {
|
||||
}
|
||||
|
||||
// Checks there is only one time index.
|
||||
let num_time_index = self
|
||||
let time_indexes = self
|
||||
.column_metadatas
|
||||
.iter()
|
||||
.filter(|col| col.semantic_type == SemanticType::Timestamp)
|
||||
.count();
|
||||
.collect::<Vec<_>>();
|
||||
ensure!(
|
||||
num_time_index == 1,
|
||||
time_indexes.len() == 1,
|
||||
InvalidMetaSnafu {
|
||||
reason: format!("expect only one time index, found {}", num_time_index),
|
||||
reason: format!(
|
||||
"expect only one time index, found {}: {}",
|
||||
time_indexes.len(),
|
||||
time_indexes
|
||||
.iter()
|
||||
.map(|c| &c.column_schema.name)
|
||||
.join(", ")
|
||||
),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user