soumyakanti3578 commented on code in PR #6383: URL: https://github.com/apache/hive/pull/6383#discussion_r3019323180
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/IdempotentDDLExecutor.java: ########## @@ -0,0 +1,130 @@ +/* + * 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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +public class IdempotentDDLExecutor { + private static final Logger LOG = LoggerFactory.getLogger(IdempotentDDLExecutor.class); + private static final Set<String> DDL_FIRST_TOKENS = Set.of( + "CREATE", "ALTER", "DROP", "RENAME", "TRUNCATE", "COMMENT"); + + private final Connection conn; + private final DbErrorCodes errorCodes; + private final HiveSchemaHelper.NestedScriptParser parser; + private final boolean verbose; + + public IdempotentDDLExecutor( + Connection conn, String dbType, HiveSchemaHelper.NestedScriptParser parser, boolean verbose) { + this.conn = conn; + this.errorCodes = DbErrorCodes.forDbType(dbType); + this.parser = parser; + this.verbose = verbose; + } + + public void executeScript(String scriptFile) throws SQLException, IOException { + LOG.info("Executing script line-by-line via IdempotentDDLExecutor: {}", scriptFile); + conn.setAutoCommit(true); + + File file = new File(scriptFile); + List<String> commands = parser.getExecutableCommands(file.getParent(), file.getName()); Review Comment: Fixed in https://github.com/apache/hive/pull/6383/commits/1459b18b3023fa8d4ea7c058207660a5129b4fc3 -- 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]
