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(crate) use row_to_batch::value_matches_type;
29pub use row_to_region::RowToRegion;
30use snafu::{OptionExt, ResultExt};
31pub use stmt_to_region::StatementToRegion;
32use table::metadata::TableInfo;
33pub use table_to_region::TableToRegion;
34pub use timestamps::extract_timestamps;
35
36use crate::error::{ColumnNotFoundSnafu, MissingTimeIndexColumnSnafu, Result};
37
38fn semantic_type(table_info: &TableInfo, column: &str) -> Result<SemanticType> {
39 let table_meta = &table_info.meta;
40 let table_schema = &table_meta.schema;
41
42 let time_index_column = &table_schema
43 .timestamp_column()
44 .with_context(|| table::error::MissingTimeIndexColumnSnafu {
45 table_name: table_info.name.clone(),
46 })
47 .context(MissingTimeIndexColumnSnafu)?
48 .name;
49
50 let semantic_type = if column == time_index_column {
51 SemanticType::Timestamp
52 } else {
53 let column_index = table_schema.column_index_by_name(column);
54 let column_index = column_index.context(ColumnNotFoundSnafu {
55 msg: format!("unable to find column {column} in table schema"),
56 })?;
57
58 if table_meta.primary_key_indices.contains(&column_index) {
59 SemanticType::Tag
60 } else {
61 SemanticType::Field
62 }
63 };
64
65 Ok(semantic_type)
66}