Skip to content

Commit 60c6504

Browse files
committed
Remove depends on DatabasesCatalog
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 098224e commit 60c6504

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

src/query/catalog/src/catalog.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,6 @@ pub trait Catalog: DynClone + Send + Sync {
171171
fn get_table_engines(&self) -> Vec<StorageDescription> {
172172
unimplemented!()
173173
}
174+
175+
fn is_case_insensitive_db(&self, db: &str) -> bool;
174176
}

src/query/service/src/catalogs/default/database_catalog.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ impl DatabaseCatalog {
9292
);
9393
Ok(res)
9494
}
95-
96-
pub fn is_case_insensitive_db(db: &str) -> bool {
97-
db.to_uppercase() == "INFORMATION_SCHEMA"
98-
}
9995
}
10096

10197
#[async_trait::async_trait]
@@ -104,14 +100,18 @@ impl Catalog for DatabaseCatalog {
104100
self
105101
}
106102

103+
fn is_case_insensitive_db(&self, db: &str) -> bool {
104+
db.to_uppercase() == "INFORMATION_SCHEMA"
105+
}
106+
107107
async fn get_database(&self, tenant: &str, db_name: &str) -> Result<Arc<dyn Database>> {
108108
if tenant.is_empty() {
109109
return Err(ErrorCode::TenantIsEmpty(
110110
"Tenant can not empty(while get database)",
111111
));
112112
}
113113

114-
let db_name = if Self::is_case_insensitive_db(db_name) {
114+
let db_name = if self.is_case_insensitive_db(db_name) {
115115
db_name.to_uppercase()
116116
} else {
117117
db_name.to_string()
@@ -243,7 +243,7 @@ impl Catalog for DatabaseCatalog {
243243
));
244244
}
245245

246-
let (db_name, table_name) = if Self::is_case_insensitive_db(db_name) {
246+
let (db_name, table_name) = if self.is_case_insensitive_db(db_name) {
247247
(db_name.to_uppercase(), table_name.to_uppercase())
248248
} else {
249249
(db_name.to_string(), table_name.to_string())
@@ -274,7 +274,7 @@ impl Catalog for DatabaseCatalog {
274274
));
275275
}
276276

277-
let db_name = if Self::is_case_insensitive_db(db_name) {
277+
let db_name = if self.is_case_insensitive_db(db_name) {
278278
db_name.to_uppercase()
279279
} else {
280280
db_name.to_string()
@@ -304,7 +304,7 @@ impl Catalog for DatabaseCatalog {
304304
));
305305
}
306306

307-
let db_name = if Self::is_case_insensitive_db(db_name) {
307+
let db_name = if self.is_case_insensitive_db(db_name) {
308308
db_name.to_uppercase()
309309
} else {
310310
db_name.to_string()

src/query/service/src/catalogs/default/immutable_catalog.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ impl Catalog for ImmutableCatalog {
8787
self
8888
}
8989

90+
fn is_case_insensitive_db(&self, _: &str) -> bool {
91+
unimplemented!()
92+
}
93+
9094
async fn get_database(&self, _tenant: &str, db_name: &str) -> Result<Arc<dyn Database>> {
9195
match db_name {
9296
"system" => Ok(self.sys_db.clone()),

src/query/service/src/catalogs/default/mutable_catalog.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ impl Catalog for MutableCatalog {
148148
self
149149
}
150150

151+
fn is_case_insensitive_db(&self, _: &str) -> bool {
152+
unimplemented!()
153+
}
154+
151155
async fn get_database(&self, tenant: &str, db_name: &str) -> Result<Arc<dyn Database>> {
152156
let db_info = self
153157
.ctx

src/query/service/src/sql/planner/binder/ddl/table.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use common_legacy_planners::*;
3838
use common_meta_app::schema::TableMeta;
3939
use tracing::debug;
4040

41-
use crate::catalogs::DatabaseCatalog;
4241
use crate::sql::binder::scalar::ScalarBinder;
4342
use crate::sql::binder::Binder;
4443
use crate::sql::binder::Visibility;
@@ -141,7 +140,11 @@ impl<'a> Binder {
141140
.map(|ident| normalize_identifier(ident, &self.name_resolution_ctx).name)
142141
.unwrap_or_else(|| self.ctx.get_current_database());
143142

144-
if DatabaseCatalog::is_case_insensitive_db(database.as_str()) {
143+
if self
144+
.ctx
145+
.get_catalog(&self.ctx.get_current_catalog())?
146+
.is_case_insensitive_db(database.as_str())
147+
{
145148
database = database.to_uppercase();
146149
}
147150

src/query/storages/hive/src/hive_catalog.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ impl Catalog for HiveCatalog {
196196
self
197197
}
198198

199+
fn is_case_insensitive_db(&self, _: &str) -> bool {
200+
false
201+
}
202+
199203
#[tracing::instrument(level = "info", skip(self))]
200204
async fn get_database(&self, _tenant: &str, db_name: &str) -> Result<Arc<dyn Database>> {
201205
let client = self.get_client()?;

0 commit comments

Comments
 (0)