From 568cd1c5ce2d2e6aaba2a60bc4e6867711f85fe2 Mon Sep 17 00:00:00 2001 From: kamille Date: Wed, 7 Dec 2022 14:48:08 +0800 Subject: [PATCH] revert pr444(https://github.com/CeresDB/ceresdb/pull/444). --- sql/src/ast.rs | 12 ++---------- sql/src/parser.rs | 7 +++---- 2 files changed, 5 insertions(+), 14 deletions(-) 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..a150083ab3 100644 --- a/sql/src/parser.rs +++ b/sql/src/parser.rs @@ -544,14 +544,13 @@ 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 {