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