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