Skip to content

Commit

Permalink
address CR.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Mar 16, 2023
1 parent 6506ffa commit 3d13d49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions sql/src/influxql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down
16 changes: 10 additions & 6 deletions sql/src/influxql/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,17 @@ fn map_column_to_influx_column(
is_timestamp_key: bool,
) -> Result<InfluxColumnType> {
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<InfluxColumnType> {
if column.name == "time" && !column.is_nullable {
Ok(InfluxColumnType::Timestamp)
Expand All @@ -144,8 +147,8 @@ fn map_column_to_influx_time_column(column: &ColumnSchema) -> Result<InfluxColum
}
}

// TODO: support more tag types.
fn map_column_to_influx_tag_column(column: &ColumnSchema) -> Result<InfluxColumnType> {
// Tag column
if matches!(column.data_type, DatumKind::String) && column.is_nullable {
Ok(InfluxColumnType::Tag)
} else {
Expand All @@ -156,6 +159,7 @@ fn map_column_to_influx_tag_column(column: &ColumnSchema) -> Result<InfluxColumn
}
}

// TODO: support more field types.
fn map_column_to_influx_field_column(column: &ColumnSchema) -> Result<InfluxColumnType> {
if column.is_nullable {
match column.data_type {
Expand Down
1 change: 0 additions & 1 deletion sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ impl<'a, P: MetaProvider> Planner<'a, P> {

pub fn influxql_stmt_to_plan(&self, statement: InfluxqlStatement) -> Result<Plan> {
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
Expand Down

0 comments on commit 3d13d49

Please sign in to comment.