KiranVelumuri commented on code in PR #5036: URL: https://github.com/apache/hive/pull/5036#discussion_r1847907976
########## beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java: ########## @@ -112,6 +122,57 @@ protected void execSql(String sqlScriptFile) throws IOException { } } + void replaceLocationForProtoLogTables(String sqlScriptFile) throws IOException { + TezConfiguration tezConf = new TezConfiguration(true); + boolean hiveProtoLoggingEnabled = true; + boolean tezProtoLoggingEnabled = true; + String hiveProtoBaseDir = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_PROTO_EVENTS_BASE_PATH); + String tezProtoBaseDir = tezConf.get(TezConfiguration.TEZ_HISTORY_LOGGING_PROTO_BASE_DIR); + String hiveLocation = "/tmp/query_data"; // if Hive protologging is not enabled, use dummy location for Hive protolog tables + String tezLocation = "/tmp"; // if Tez protologging is not enabled, use dummy location for Tez protolog tables + String line; + StringBuilder newLine = new StringBuilder(); + Map<String, String> replacements = new HashMap<>(); + + if (isEmpty(hiveProtoBaseDir)) { + LOG.error("Hive conf variable hive.hook.proto.base-directory is not set for creating protologging tables"); + hiveProtoLoggingEnabled = false; + } + if (isEmpty(tezProtoBaseDir)) { + LOG.error("Tez conf variable tez.history.logging.proto-base-dir is not set for creating protologging tables"); + tezProtoLoggingEnabled = false; + } + + if (hiveProtoLoggingEnabled) { + String hiveProtoScheme = new Path(hiveProtoBaseDir).getFileSystem(conf).getScheme() + ":///"; + hiveLocation = new Path(hiveProtoBaseDir).getFileSystem(conf).getUri().isAbsolute() ? hiveProtoBaseDir : hiveProtoScheme + hiveProtoBaseDir; + } + if (tezProtoLoggingEnabled) { + String tezProtoScheme = new Path(tezProtoBaseDir).getFileSystem(tezConf).getScheme() + ":///"; + tezLocation = new Path(tezProtoBaseDir).getFileSystem(tezConf).getUri().isAbsolute() ? tezProtoBaseDir : tezProtoScheme + tezProtoBaseDir; + } + + replacements.put("_REPLACE_WITH_QUERY_DATA_LOCATION_", hiveLocation); + replacements.put("_REPLACE_WITH_APP_DATA_LOCATION_", tezLocation + "/app_data"); + replacements.put("_REPLACE_WITH_DAG_DATA_LOCATION_", tezLocation + "/dag_data"); + replacements.put("_REPLACE_WITH_DAG_META_LOCATION_", tezLocation + "/dag_meta"); + + try (BufferedReader reader = new BufferedReader(new FileReader(sqlScriptFile))) { + while ((line = reader.readLine()) != null) { + for (Map.Entry<String, String> entry : replacements.entrySet()) { + if (line.contains(entry.getKey())) { + line = line.replace(entry.getKey(), entry.getValue()); + } + } + newLine.append(line).append("\n"); + } + } + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(sqlScriptFile))) { Review Comment: The original script is not modified. A temporary copy of the original script is loaded which is overwritten. In that case, it should be fine I suppose. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org