Skip to content

Commit

Permalink
Merge pull request #27885 from maddyblue/cluster-insight
Browse files Browse the repository at this point in the history
adapter: show cluster name and id in insights
  • Loading branch information
maddyblue authored Jun 26, 2024
2 parents 1d680a5 + eb5c434 commit e59a416
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/adapter/src/coord/sequencer/inner/create_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ impl Coordinator {
&features,
&expr_humanizer,
None,
Some(target_cluster.name.as_str()),
Some(target_cluster),
df_meta,
stage,
plan::ExplaineeStatementKind::CreateIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ impl Coordinator {
&features,
&expr_humanizer,
None,
Some(target_cluster.name.as_str()),
Some(target_cluster),
df_meta,
stage,
plan::ExplaineeStatementKind::CreateMaterializedView,
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/src/coord/sequencer/inner/peek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ impl Coordinator {
&features,
&self.catalog().for_session(session),
Some(plan.finishing),
Some(target_cluster.name.as_str()),
Some(target_cluster),
df_meta,
insights_ctx,
)
Expand Down Expand Up @@ -1028,7 +1028,7 @@ impl Coordinator {
&features,
&expr_humanizer,
finishing,
Some(target_cluster.name.as_str()),
Some(target_cluster),
df_meta,
stage,
plan::ExplaineeStatementKind::Select,
Expand Down
14 changes: 11 additions & 3 deletions src/adapter/src/explain/optimizer_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use std::fmt::{Debug, Display};
use std::sync::Arc;

use mz_catalog::memory::objects::Cluster;
use mz_compute_types::dataflows::DataflowDescription;
use mz_compute_types::plan::Plan;
use mz_expr::explain::ExplainContext;
Expand Down Expand Up @@ -133,7 +134,7 @@ impl OptimizerTrace {
features: &OptimizerFeatures,
humanizer: &dyn ExprHumanizer,
row_set_finishing: Option<RowSetFinishing>,
target_cluster: Option<&str>,
target_cluster: Option<&Cluster>,
dataflow_metainfo: DataflowMetainfo,
stage: ExplainStage,
stmt_kind: plan::ExplaineeStatementKind,
Expand All @@ -146,7 +147,7 @@ impl OptimizerTrace {
features,
humanizer,
row_set_finishing.clone(),
target_cluster,
target_cluster.map(|c| c.name.as_str()),
dataflow_metainfo.clone(),
)
};
Expand Down Expand Up @@ -213,6 +214,12 @@ impl OptimizerTrace {
.await;
}
}
let cluster = target_cluster.map(|c| {
serde_json::json!({
"name": c.name,
"id": c.id,
})
});

let output = serde_json::json!({
"plans": {
Expand All @@ -223,6 +230,7 @@ impl OptimizerTrace {
}
},
"insights": plan_insights,
"cluster": cluster,
});
let output = serde_json::to_string_pretty(&output).expect("JSON string");
vec![Row::pack_slice(&[Datum::from(output.as_str())])]
Expand Down Expand Up @@ -289,7 +297,7 @@ impl OptimizerTrace {
features: &OptimizerFeatures,
humanizer: &dyn ExprHumanizer,
row_set_finishing: Option<RowSetFinishing>,
target_cluster: Option<&str>,
target_cluster: Option<&Cluster>,
dataflow_metainfo: DataflowMetainfo,
insights_ctx: Option<PlanInsightsContext>,
) -> Result<String, AdapterError> {
Expand Down
Loading

0 comments on commit e59a416

Please sign in to comment.