Skip to content

Commit

Permalink
revert pr444(apache#444).
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Dec 7, 2022
1 parent bb2ee3f commit 568cd1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
12 changes: 2 additions & 10 deletions sql/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -33,22 +33,14 @@ 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 {
fn to_string(&self) -> String {
self.0
.0
.iter()
.map(Self::normalize_ident)
.map(|ident| ident.value.as_str())
.collect::<Vec<_>>()
.join(".")
}
Expand Down
7 changes: 3 additions & 4 deletions sql/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 568cd1c

Please sign in to comment.