diff --git a/sql/src/ast.rs b/sql/src/ast.rs index d2a6fe1264..729fc8ff43 100644 --- a/sql/src/ast.rs +++ b/sql/src/ast.rs @@ -3,7 +3,7 @@ //! SQL statement use sqlparser::ast::{ - ColumnDef, Ident, ObjectName, SqlOption, Statement as SqlStatement, TableConstraint, + ColumnDef, ObjectName, SqlOption, Statement as SqlStatement, TableConstraint, }; /// Statement representations @@ -33,14 +33,6 @@ impl TableName { pub fn is_empty(&self) -> bool { self.0 .0.is_empty() } - - // Normalize an identifer to a lowercase string unless the identifier is quoted. - fn normalize_ident(id: &Ident) -> String { - match id.quote_style { - Some(_) => id.value.clone(), - None => id.value.to_ascii_lowercase(), - } - } } impl ToString for TableName { @@ -48,7 +40,7 @@ impl ToString for TableName { self.0 .0 .iter() - .map(Self::normalize_ident) + .map(|ident| ident.value.as_str()) .collect::>() .join(".") } diff --git a/sql/src/parser.rs b/sql/src/parser.rs index e8a8ac0730..c2782e1e04 100644 --- a/sql/src/parser.rs +++ b/sql/src/parser.rs @@ -544,14 +544,12 @@ fn build_timestamp_key_constraint(col_defs: &[ColumnDef], constraints: &mut Vec< } } -/// Add quotes in table name, for example: -/// -/// table --> `table` +/// Add quotes in table name (for example: convert table to `table`). /// /// It is used to process table name in `SELECT`, for preventing `datafusion` /// converting the table name to lowercase, because `CeresDB` only support /// case-sensitive in sql. -// TODO: other items(such as: alias, column name) are not normalized now. +// TODO: maybe other items(such as: alias, column name) need to be normalized, too. pub fn maybe_normalize_table_name(statement: SqlStatement) -> SqlStatement { let original_statement = statement.clone(); if let SqlStatement::Query(query) = statement {