Copilot commented on code in PR #6636: URL: https://github.com/apache/hive/pull/6636#discussion_r3694235214
########## standalone-metastore/metastore-server/src/main/sql/postgres/rebuild-indexes.postgres.sql: ########## @@ -0,0 +1,176 @@ +-- 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 + Review Comment: The Apache license header is incomplete: it ends after “governing permissions and” and is missing the final “limitations under the License.” line. This should be fixed to match the standard ASF header used in the other SQL scripts. ########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/HiveSchemaHelper.java: ########## @@ -42,7 +42,7 @@ public class HiveSchemaHelper { public static final String DB_HIVE = "hive"; public static final String DB_MSSQL = "mssql"; public static final String DB_MYSQL = "mysql"; - public static final String DB_POSTGRACE = "postgres"; + public static final String DB_POSTGRES = "postgres"; public static final String DB_ORACLE = "oracle"; Review Comment: Renaming the public constant from DB_POSTGRACE to DB_POSTGRES is source/binary incompatible for any downstream code that may reference the old field name. Consider keeping DB_POSTGRACE as a deprecated alias to DB_POSTGRES for compatibility. ########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/SchemaToolTaskRebuildIndexes.java: ########## @@ -0,0 +1,68 @@ +/* + * 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.hadoop.hive.metastore.tools.schematool; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; + +import org.apache.hadoop.hive.metastore.HiveMetaException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class SchemaToolTaskRebuildIndexes extends SchemaToolTask { + + private static final Logger LOG = LoggerFactory.getLogger(SchemaToolTaskRebuildIndexes.class); + static final String REBUILD_INDEXES_FILE_PREFIX = "rebuild-indexes"; + + @Override + void setCommandLineArguments(SchemaToolCommandLine cl) { + } + + @Override + void execute() throws HiveMetaException { + String dbType = schemaTool.getDbType(); + String scriptDir = schemaTool.getMetaStoreSchemaInfo().getMetaStoreScriptDir(); + String scriptFile = REBUILD_INDEXES_FILE_PREFIX + "." + dbType + ".sql"; + File script = new File(scriptDir, scriptFile); + + if (!script.exists()) { + throw new HiveMetaException( + "-rebuildIndexes is not supported for -dbType " + dbType + ". " + + "Expected script not found: " + script.getAbsolutePath()); + } + + if (schemaTool.isDryRun()) { + try { + LOG.info("Dry run: would execute {}", script.getAbsolutePath()); + LOG.info(new String(Files.readAllBytes(script.toPath()))); + } catch (IOException e) { Review Comment: Dry-run logging reads the SQL script bytes and converts them to a String without specifying a charset, which can produce garbled output on non-UTF-8 platforms. Use an explicit charset when reading/logging the script. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
