soumyakanti3578 commented on code in PR #6383:
URL: https://github.com/apache/hive/pull/6383#discussion_r3018562222
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/HiveSchemaHelper.java:
##########
@@ -253,6 +265,56 @@ public boolean needsQuotedIdentifier() {
return false;
}
+ @Override
+ public List<String> getExecutableCommands(String scriptDir, String
scriptFile)
+ throws IllegalFormatException, IOException {
+ return getExecutableCommands(scriptDir, scriptFile, false);
+ }
+
+ @Override
+ public List<String> getExecutableCommands(String scriptDir, String
scriptFile, boolean fixQuotes)
+ throws IllegalFormatException, IOException {
+ List<String> commands = new java.util.ArrayList<>();
+
+ try (BufferedReader bfReader =
+ new BufferedReader(new FileReader(scriptDir +
File.separatorChar + scriptFile))) {
+ String currLine;
+ String currentCommand = null;
+
+ while ((currLine = bfReader.readLine()) != null) {
+ currLine = fixQuotesFromCurrentLine(fixQuotes, currLine.trim());
+
+ if (currLine.isEmpty()) {
+ continue;
+ }
+
+ currentCommand = currentCommand == null ? currLine : currentCommand
+ " " + currLine;
+
+ if (!isPartialCommand(currLine)) {
+ if (!isNonExecCommand(currentCommand)) {
+ currentCommand = cleanseCommand(currentCommand);
+ if (isNestedScript(currentCommand)) {
+ String currScript = getScriptName(currentCommand);
+ commands.addAll(getExecutableCommands(scriptDir, currScript,
fixQuotes));
+ } else {
+ commands.add(currentCommand.trim());
+ }
+ }
+ currentCommand = null;
+ }
+
+ }
Review Comment:
We run into this issue when the last executable sql line doesn't end with a
delimiter (semi-colon for most cases).
The current scripts do not have this problem and won't run into this. For
future scripts it might be better just to fail fast to indicate that the script
is incorrect.
I am adding a check for this and throwing an exception.
--
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]