fix(alerting): use ALTER TABLE MODIFY SETTING to enable projections on executions ReplacingMergeTree
Investigated three approaches for CH 24.12: - Inline SETTINGS on ADD PROJECTION: rejected (UNKNOWN_SETTING — not a query-level setting). - ALTER TABLE MODIFY SETTING deduplicate_merge_projection_mode='rebuild': works; persists in table metadata across connection restarts; runs before ADD PROJECTION in the SQL script. - Session-level JDBC URL param: not pursued (MODIFY SETTING is strictly better). alerting_projections.sql now runs MODIFY SETTING before the two executions ADD PROJECTIONs. AlertingProjectionsIT strengthened to assert all four projections (including alerting_app_status and alerting_route_status on executions) exist after schema init. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -34,17 +34,19 @@ class AlertingProjectionsIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
void mergeTreeProjectionsExistAfterInit() {
|
||||
// logs and agent_metrics are plain MergeTree — projections always succeed.
|
||||
// executions is ReplacingMergeTree; its projections require the session setting
|
||||
// deduplicate_merge_projection_mode='rebuild' which is unavailable via JDBC pool,
|
||||
// so they are best-effort and not asserted here.
|
||||
void allFourProjectionsExistAfterInit() {
|
||||
// logs and agent_metrics are plain MergeTree — always succeed.
|
||||
// executions is ReplacingMergeTree; its projections now succeed because
|
||||
// alerting_projections.sql runs ALTER TABLE executions MODIFY SETTING
|
||||
// deduplicate_merge_projection_mode='rebuild' before the ADD PROJECTION statements.
|
||||
List<String> names = jdbc.queryForList(
|
||||
"SELECT name FROM system.projections WHERE table IN ('logs', 'agent_metrics')",
|
||||
"SELECT name FROM system.projections WHERE table IN ('logs', 'agent_metrics', 'executions')",
|
||||
String.class);
|
||||
|
||||
assertThat(names).contains(
|
||||
assertThat(names).containsExactlyInAnyOrder(
|
||||
"alerting_app_level",
|
||||
"alerting_instance_metric");
|
||||
"alerting_instance_metric",
|
||||
"alerting_app_status",
|
||||
"alerting_route_status");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user