From b0c472229d93d747dcaa380b66d76ce6a2263a3e Mon Sep 17 00:00:00 2001 From: "xu.guo" Date: Tue, 14 Mar 2023 19:51:43 +0800 Subject: [PATCH] Fix Beeline with -i run sql faild --- .../java/org/apache/hive/beeline/KyuubiCommands.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java index 57ac9975d3f..1e41093645c 100644 --- a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java +++ b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java @@ -523,15 +523,19 @@ public String handleMultiLineCmd(String line) throws IOException { "Console reader not initialized. This could happen when there " + "is a multi-line command using -e option and which requires further reading from console"); } + + if(beeLine.getOpts().getInitFiles() != null) { + beeLine.getConsoleReader().shutdown(); + beeLine.setConsoleReader(new ConsoleReader(beeLine.getInputStream(), beeLine.getErrorStream())); + } + if (beeLine.getOpts().isSilent() && beeLine.getOpts().getScriptFile() != null) { extra = beeLine.getConsoleReader().readLine(null, mask); } else { extra = beeLine.getConsoleReader().readLine(prompt.toString()); } - if(beeLine.getOpts().getInitFiles() != null) { - beeLine.setConsoleReader(new ConsoleReader(beeLine.getInputStream(), beeLine.getErrorStream())); - } + if (extra == null) { // it happens when using -f and the line of cmds does not end with ; break; }