add exists_table in the catalog trait
use std::sync::Arc;
+use common_exception::ErrorCode;
use common_exception::Result;
use common_meta_types::CreateDatabaseReply;
use common_meta_types::MetaId;
@@ -82,4 +83,17 @@ pub trait Catalog {
async fn drop_database(&self, plan: DropDatabasePlan) -> Result<()>;
async fn exists_database(&self, db_name: &str) -> Result<bool>;
+
+ async fn exists_table(&self, db_name: &str, table_name: &str) -> Result<bool> {
+ match self.get_table(db_name, table_name).await {
+ Ok(_) => Ok(true),
+ Err(err) => {
+ if err.code() == ErrorCode::UnknownTableCode() {
+ Ok(false)
+ } else {
+ Err(err)
+ }
+ }
+ }
+ }
}
