aturoczy commented on code in PR #5036:
URL: https://github.com/apache/hive/pull/5036#discussion_r1466762145


##########
beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java:
##########
@@ -112,6 +121,40 @@ protected void execSql(String sqlScriptFile) throws 
IOException {
     }
   }
 
+  void replaceLocationForProtoLogTables(String sqlScriptFile) throws 
IOException {
+    TezConfiguration tezConf = new TezConfiguration(true);
+    String hiveProtoBaseDir = HiveConf.getVar(conf, 
HiveConf.ConfVars.HIVE_PROTO_EVENTS_BASE_PATH);
+    String tezProtoBaseDir = 
tezConf.get(TezConfiguration.TEZ_HISTORY_LOGGING_PROTO_BASE_DIR);
+
+    if (isEmpty(hiveProtoBaseDir)) {
+      throw new IOException("Hive conf variable hive.hook.proto.base-directory 
is not set for creating protologging tables");
+    }
+    if (isEmpty(tezProtoBaseDir)) {
+      throw new IOException("Tez conf variable 
tez.history.logging.proto-base-dir is not set for creating protologging 
tables");
+    }
+
+    Map<String, String> replacements = new HashMap<>();
+    replacements.put("_REPLACE_WITH_QUERY_DATA_LOCATION_", "hdfs:///" + 
hiveProtoBaseDir);
+    replacements.put("_REPLACE_WITH_APP_DATA_LOCATION_", "hdfs:///" + 
tezProtoBaseDir + "/app_data");
+    replacements.put("_REPLACE_WITH_DAG_DATA_LOCATION_", "hdfs:///" + 
tezProtoBaseDir + "/dag_data");
+    replacements.put("_REPLACE_WITH_DAG_META_LOCATION_", "hdfs:///" + 
tezProtoBaseDir + "/dag_meta");
+
+    BufferedReader reader = new BufferedReader(new FileReader(sqlScriptFile));
+    String line;
+    StringBuilder newLine = new StringBuilder();
+    while ((line = reader.readLine()) != null) {
+      for (String s: replacements.keySet()) {
+        if (line.contains(s)) {
+          line = line.replace(s, replacements.get(s));

Review Comment:
   Could you please elaborate why it needs to replace? I guess it has a 
business logic part, but from review perspective hard to understand. 



-- 
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]

Reply via email to