Skip to content

Commit

Permalink
Remove breakable usage
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyum committed Oct 13, 2019
1 parent bdf6ac4 commit 48364a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
Expand Up @@ -23,7 +23,6 @@ import java.util.{ArrayList => JArrayList, List => JList, Locale}
import java.util.concurrent.TimeUnit

import scala.collection.JavaConverters._
import scala.util.control.Breaks._

import jline.console.ConsoleReader
import jline.console.history.FileHistory
Expand Down Expand Up @@ -475,32 +474,24 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {

try {
var lastRet: Int = 0
var ret: Int = 0

// we can not use "split" function directly as ";" may be quoted
val commands = splitSemiColon(line).asScala

var command: String = ""
for (oneCmd <- commands) {

breakable {
if (StringUtils.endsWith(oneCmd, "\\")) {
command += StringUtils.chop(oneCmd) + ";"
break
} else {
command += oneCmd
}
if (StringUtils.isBlank(command)) {
break
}

ret = processCmd(command)
command = ""
lastRet = ret
val ignoreErrors = HiveConf.getBoolVar(conf, HiveConf.ConfVars.CLIIGNOREERRORS)
if (ret != 0 && !ignoreErrors) {
CommandProcessorFactory.clean(conf.asInstanceOf[HiveConf])
return ret
if (StringUtils.endsWith(oneCmd, "\\")) {
command += StringUtils.chop(oneCmd) + ";"
} else {
command += oneCmd
if (!StringUtils.isBlank(command)) {
val ret = processCmd(command)
command = ""
lastRet = ret
val ignoreErrors = HiveConf.getBoolVar(conf, HiveConf.ConfVars.CLIIGNOREERRORS)
if (ret != 0 && !ignoreErrors) {
CommandProcessorFactory.clean(conf.asInstanceOf[HiveConf])
ret
}
}
}
}
Expand Down
Expand Up @@ -385,7 +385,7 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging {
)
}

test("Should not split semicolon within quoted string literals") {
test("SPARK-26321 Should not split semicolon within quoted string literals") {
runCliWithin(3.minute)(
"""select 'Test1', "^;^";""" -> "Test1\t^;^",
"""select 'Test2', "\";";""" -> "Test2\t\";",
Expand Down

0 comments on commit 48364a7

Please sign in to comment.