diff --git a/sql/src/influxql/planner.rs b/sql/src/influxql/planner.rs index 0c8496a21e..bdefa32cbc 100644 --- a/sql/src/influxql/planner.rs +++ b/sql/src/influxql/planner.rs @@ -9,9 +9,8 @@ use influxql_logical_planner::planner::InfluxQLToLogicalPlan; use influxql_parser::statement::Statement as InfluxqlStatement; use snafu::ResultExt; -use super::provider::InfluxSchemaProviderImpl; use crate::{ - influxql::error::*, + influxql::{error::*, provider::InfluxSchemaProviderImpl}, plan::{Plan, QueryPlan}, provider::{ContextProviderAdapter, MetaProvider}, }; diff --git a/sql/src/influxql/provider.rs b/sql/src/influxql/provider.rs index 7694b26c1b..8a19eb1f41 100644 --- a/sql/src/influxql/provider.rs +++ b/sql/src/influxql/provider.rs @@ -125,14 +125,17 @@ fn map_column_to_influx_column( is_timestamp_key: bool, ) -> Result { if is_timestamp_key { - map_column_to_influx_time_column(column) - } else if column.is_tag { - map_column_to_influx_tag_column(column) - } else { - map_column_to_influx_field_column(column) + return map_column_to_influx_time_column(column); + } + + if column.is_tag { + return map_column_to_influx_tag_column(column); } + + map_column_to_influx_field_column(column) } +// TODO: don't restrict the time column name. fn map_column_to_influx_time_column(column: &ColumnSchema) -> Result { if column.name == "time" && !column.is_nullable { Ok(InfluxColumnType::Timestamp) @@ -144,8 +147,8 @@ fn map_column_to_influx_time_column(column: &ColumnSchema) -> Result Result { - // Tag column if matches!(column.data_type, DatumKind::String) && column.is_nullable { Ok(InfluxColumnType::Tag) } else { @@ -156,6 +159,7 @@ fn map_column_to_influx_tag_column(column: &ColumnSchema) -> Result Result { if column.is_nullable { match column.data_type { diff --git a/sql/src/planner.rs b/sql/src/planner.rs index 47aabef7b9..896b43b25d 100644 --- a/sql/src/planner.rs +++ b/sql/src/planner.rs @@ -331,7 +331,6 @@ impl<'a, P: MetaProvider> Planner<'a, P> { pub fn influxql_stmt_to_plan(&self, statement: InfluxqlStatement) -> Result { let adapter = ContextProviderAdapter::new(self.provider, self.read_parallelism); - // let planner = PlannerDelegate::new(adapter); let influxql_planner = crate::influxql::planner::Planner::new(adapter); influxql_planner