obelix74 commented on code in PR #3385: URL: https://github.com/apache/polaris/pull/3385#discussion_r2819839601
########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetricsSchemaBootstrap.java: ########## @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.persistence.relational.jdbc; + +import java.sql.SQLException; +import java.util.List; +import org.apache.polaris.core.persistence.metrics.MetricsSchemaBootstrap; +import org.apache.polaris.persistence.relational.jdbc.models.MetricsSchemaVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * JDBC implementation of {@link MetricsSchemaBootstrap}. + * + * <p>This implementation creates the metrics schema tables (scan_metrics_report, + * commit_metrics_report, metrics_version) in the configured JDBC database. + * + * <p>The metrics schema is separate from the entity schema and can be bootstrapped independently. + * This allows operators to add metrics support to existing Polaris deployments without + * re-bootstrapping the entity schema. + */ +public class JdbcMetricsSchemaBootstrap implements MetricsSchemaBootstrap { + + private static final Logger LOGGER = LoggerFactory.getLogger(JdbcMetricsSchemaBootstrap.class); + + /** Current metrics schema version. */ + private static final int METRICS_SCHEMA_VERSION = 1; + + private final DatasourceOperations datasourceOperations; + + public JdbcMetricsSchemaBootstrap(DatasourceOperations datasourceOperations) { + this.datasourceOperations = datasourceOperations; + } + + @Override + public void bootstrap(String realmId) { + if (isBootstrapped(realmId)) { + LOGGER.debug("Metrics schema already bootstrapped for realm: {}", realmId); + return; Review Comment: I've added support for schema versioning and upgrades in its own commit. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
