Skip to content

Commit 3968a07

Browse files
committed
feat(cubestore): Support EXPLAIN for meta queries
1 parent 8208419 commit 3968a07

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

rust/cubestore/cubestore/src/queryplanner/pretty_printers.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::queryplanner::serialized_plan::{IndexSnapshot, RowRange};
3030
use crate::queryplanner::tail_limit::TailLimitExec;
3131
use crate::queryplanner::topk::ClusterAggregateTopK;
3232
use crate::queryplanner::topk::{AggregateTopKExec, SortColumn};
33-
use crate::queryplanner::CubeTableLogical;
33+
use crate::queryplanner::{CubeTableLogical, InfoSchemaTableProvider};
3434
use datafusion::cube_ext::join::CrossJoinExec;
3535
use datafusion::cube_ext::joinagg::CrossJoinAggExec;
3636
use datafusion::cube_ext::rolling::RollingWindowAggExec;
@@ -257,6 +257,8 @@ fn pp_source(t: &dyn TableProvider) -> String {
257257
format!("CubeTable(index: {})", pp_index(t.index_snapshot()))
258258
} else if let Some(t) = t.as_any().downcast_ref::<InlineTableProvider>() {
259259
format!("InlineTableProvider(data: {} rows)", t.get_data().len())
260+
} else if t.as_any().downcast_ref::<InfoSchemaTableProvider>().is_some() {
261+
"InfoSchemaTableProvider".to_string()
260262
} else {
261263
panic!("unknown table provider");
262264
}

rust/cubestore/cubestore/src/sql/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,22 @@ impl SqlServiceImpl {
461461
};
462462
Ok(res)
463463
}
464-
_ => Err(CubeError::user(
465-
"Explain not supported for selects from system tables".to_string(),
466-
)),
464+
QueryPlan::Meta(logical_plan) => {
465+
if !analyze {
466+
Ok(DataFrame::new(
467+
vec![Column::new(
468+
"logical plan".to_string(),
469+
ColumnType::String,
470+
0,
471+
)],
472+
vec![Row::new(vec![TableValue::String(pp_plan(&logical_plan))])],
473+
))
474+
} else {
475+
Err(CubeError::user(
476+
"EXPLAIN ANALYZE is not supported for selects from system tables".to_string(),
477+
))
478+
}
479+
}
467480
}?;
468481
Ok(Arc::new(res))
469482
}

0 commit comments

Comments
 (0)