cleanup tmp check code after
use std::sync::Arc;
-use common_exception::ErrorCode;
use common_exception::Result;
use common_meta_types::GrantObject;
use common_planners::GrantPrivilegePlan;
@@ -22,7 +21,6 @@ use common_streams::DataBlockStream;
use common_streams::SendableDataBlockStream;
use common_tracing::tracing;
-use crate::catalogs::impls::DatabaseCatalog;
use crate::catalogs::Catalog;
use crate::interpreters::Interpreter;
use crate::interpreters::InterpreterPtr;
@@ -41,25 +39,6 @@ impl GrantPrivilegeInterpreter {
) -> Result<InterpreterPtr> {
Ok(Arc::new(GrantPrivilegeInterpreter { ctx, plan }))
}
-
- // TODO: refactor out this after adding a exists table in Catalog
- async fn check_table_exists(
- &self,
- catalog: Arc<DatabaseCatalog>,
- database_name: &str,
- table_name: &str,
- ) -> Result<bool> {
- match catalog.get_table(database_name, table_name).await {
- Ok(_) => Ok(true),
- Err(err) => {
- if err.code() == ErrorCode::UnknownTableCode() {
- Ok(false)
- } else {
- Err(err)
- }
- }
- }
- }
}
#[async_trait::async_trait]
@@ -78,8 +57,9 @@ impl Interpreter for GrantPrivilegeInterpreter {
match &plan.on {
GrantObject::Table(database_name, table_name) => {
- if !self
- .check_table_exists(catalog.clone(), database_name, table_name)
+ if !catalog
+ .as_ref()
+ .exists_table(database_name, table_name)
.await?
{
return Err(common_exception::ErrorCode::UnknownTable(format!(
