refactor: use DummyCatalog to construct query engine for datanode (#6723)

* refactor: use DummyCatalog to construct query engine for datanode

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>

* fix clippy

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>

* move to query/dummy_catalog

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>

---------

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
Zhenchi
2025-08-13 17:49:51 +08:00
committed by GitHub
parent a678b4dfd6
commit dea87b7e57
7 changed files with 115 additions and 24 deletions

View File

@@ -20,6 +20,8 @@ use std::sync::{Arc, Mutex};
use api::v1::SemanticType;
use async_trait::async_trait;
use catalog::error::Result as CatalogResult;
use catalog::{CatalogManager, CatalogManagerRef};
use common_recordbatch::filter::SimpleFilterEvaluator;
use common_recordbatch::OrderOption;
use datafusion::catalog::{CatalogProvider, CatalogProviderList, SchemaProvider, Session};
@@ -28,12 +30,15 @@ use datafusion::physical_plan::ExecutionPlan;
use datafusion_common::DataFusionError;
use datafusion_expr::{Expr, TableProviderFilterPushDown, TableType};
use datatypes::arrow::datatypes::SchemaRef;
use session::context::QueryContextRef;
use futures::stream::BoxStream;
use session::context::{QueryContext, QueryContextRef};
use snafu::ResultExt;
use store_api::metadata::RegionMetadataRef;
use store_api::region_engine::RegionEngineRef;
use store_api::storage::{RegionId, ScanRequest, TimeSeriesDistribution, TimeSeriesRowSelector};
use table::metadata::{TableId, TableInfoRef};
use table::table::scan::RegionScanExec;
use table::TableRef;
use crate::error::{GetRegionMetadataSnafu, Result};
@@ -322,3 +327,108 @@ pub trait TableProviderFactory: Send + Sync {
}
pub type TableProviderFactoryRef = Arc<dyn TableProviderFactory>;
/// A dummy catalog manager that always returns empty results.
///
/// Used to fill the arg of `QueryEngineFactory::new_with_plugins` in datanode.
pub struct DummyCatalogManager;
impl DummyCatalogManager {
/// Returns a new `CatalogManagerRef` instance.
pub fn arc() -> CatalogManagerRef {
Arc::new(Self)
}
}
#[async_trait::async_trait]
impl CatalogManager for DummyCatalogManager {
fn as_any(&self) -> &dyn Any {
self
}
async fn catalog_names(&self) -> CatalogResult<Vec<String>> {
Ok(vec![])
}
async fn schema_names(
&self,
_catalog: &str,
_query_ctx: Option<&QueryContext>,
) -> CatalogResult<Vec<String>> {
Ok(vec![])
}
async fn table_names(
&self,
_catalog: &str,
_schema: &str,
_query_ctx: Option<&QueryContext>,
) -> CatalogResult<Vec<String>> {
Ok(vec![])
}
async fn catalog_exists(&self, _catalog: &str) -> CatalogResult<bool> {
Ok(false)
}
async fn schema_exists(
&self,
_catalog: &str,
_schema: &str,
_query_ctx: Option<&QueryContext>,
) -> CatalogResult<bool> {
Ok(false)
}
async fn table_exists(
&self,
_catalog: &str,
_schema: &str,
_table: &str,
_query_ctx: Option<&QueryContext>,
) -> CatalogResult<bool> {
Ok(false)
}
async fn table(
&self,
_catalog: &str,
_schema: &str,
_table_name: &str,
_query_ctx: Option<&QueryContext>,
) -> CatalogResult<Option<TableRef>> {
Ok(None)
}
async fn table_id(
&self,
_catalog: &str,
_schema: &str,
_table_name: &str,
_query_ctx: Option<&QueryContext>,
) -> CatalogResult<Option<TableId>> {
Ok(None)
}
async fn table_info_by_id(&self, _table_id: TableId) -> CatalogResult<Option<TableInfoRef>> {
Ok(None)
}
async fn tables_by_ids(
&self,
_catalog: &str,
_schema: &str,
_table_ids: &[TableId],
) -> CatalogResult<Vec<TableRef>> {
Ok(vec![])
}
fn tables<'a>(
&'a self,
_catalog: &'a str,
_schema: &'a str,
_query_ctx: Option<&'a QueryContext>,
) -> BoxStream<'a, CatalogResult<TableRef>> {
Box::pin(futures::stream::empty())
}
}