operator/req_convert/
insert.rs1mod column_to_row;
16mod fill_impure_default;
17mod row_to_region;
18mod stmt_to_region;
19mod table_to_region;
20
21use api::v1::SemanticType;
22pub use column_to_row::ColumnToRow;
23pub use fill_impure_default::fill_reqs_with_impure_default;
24pub use row_to_region::RowToRegion;
25use snafu::{OptionExt, ResultExt};
26pub use stmt_to_region::StatementToRegion;
27use table::metadata::TableInfo;
28pub use table_to_region::TableToRegion;
29
30use crate::error::{ColumnNotFoundSnafu, MissingTimeIndexColumnSnafu, Result};
31
32fn semantic_type(table_info: &TableInfo, column: &str) -> Result<SemanticType> {
33 let table_meta = &table_info.meta;
34 let table_schema = &table_meta.schema;
35
36 let time_index_column = &table_schema
37 .timestamp_column()
38 .with_context(|| table::error::MissingTimeIndexColumnSnafu {
39 table_name: table_info.name.to_string(),
40 })
41 .context(MissingTimeIndexColumnSnafu)?
42 .name;
43
44 let semantic_type = if column == time_index_column {
45 SemanticType::Timestamp
46 } else {
47 let column_index = table_schema.column_index_by_name(column);
48 let column_index = column_index.context(ColumnNotFoundSnafu {
49 msg: format!("unable to find column {column} in table schema"),
50 })?;
51
52 if table_meta.primary_key_indices.contains(&column_index) {
53 SemanticType::Tag
54 } else {
55 SemanticType::Field
56 }
57 };
58
59 Ok(semantic_type)
60}