Skip to content

Commit

Permalink
Fix python ut
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Feb 13, 2023
1 parent c66ad22 commit 37cc70a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class ExecutePython(
val output = response.map(_.content.getOutput()).getOrElse("")
val ename = response.map(_.content.getEname()).getOrElse("")
val evalue = response.map(_.content.getEvalue()).getOrElse("")
val traceback = response.map(_.content.getTraceback()).getOrElse(Array.empty)
val traceback = response.map(_.content.getTraceback()).getOrElse(Seq.empty)
iter =
new ArrayFetchIterator[Row](Array(Row(output, status, ename, evalue, Row(traceback: _*))))
new ArrayFetchIterator[Row](Array(Row(output, status, ename, evalue, traceback)))
setState(OperationState.FINISHED)
} else {
throw KyuubiSQLException(s"Interpret error:\n$statement\n $response")
Expand Down Expand Up @@ -210,7 +210,7 @@ case class SessionPythonWorker(
stdin.flush()
val pythonResponse = Option(stdout.readLine()).map(ExecutePython.fromJson[PythonResponse](_))
// throw exception if internal python code fail
if (internal && pythonResponse.map(_.content.status) != Some(PythonResponse.OK_STATUS)) {
if (internal && !pythonResponse.map(_.content.status).contains(PythonResponse.OK_STATUS)) {
throw KyuubiSQLException(s"Internal python code $code failure: $pythonResponse")
}
pythonResponse
Expand Down Expand Up @@ -328,7 +328,7 @@ object ExecutePython extends Logging {
}

// for test
def defaultSparkHome(): String = {
def defaultSparkHome: String = {
val homeDirFilter: FilenameFilter = (dir: File, name: String) =>
dir.isDirectory && name.contains("spark-") && !name.contains("-engine")
// get from kyuubi-server/../externals/kyuubi-download/target
Expand Down Expand Up @@ -418,7 +418,7 @@ case class PythonResponseContent(
data: Map[String, String],
ename: String,
evalue: String,
traceback: Array[String],
traceback: Seq[String],
status: String) {
def getOutput(): String = {
Option(data)
Expand All @@ -431,7 +431,7 @@ case class PythonResponseContent(
def getEvalue(): String = {
Option(evalue).getOrElse("")
}
def getTraceback(): Array[String] = {
Option(traceback).getOrElse(Array.empty)
def getTraceback(): Seq[String] = {
Option(traceback).getOrElse(Seq.empty)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ abstract class SparkOperation(session: Session)
} else {
val taken = iter.take(rowSetSize)
RowSet.toTRowSet(
taken.toList.asInstanceOf[List[Row]],
taken.toSeq.asInstanceOf[Seq[Row]],
resultSchema,
getProtocolVersion,
timeZone)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ object RowSet {
val row = rows(i)
nulls.set(i, row.isNullAt(ordinal))
values.add(
HiveResult.toHiveString((row.get(ordinal), typ), false, getTimeFormatters(timeZone)))
HiveResult.toHiveString(row.get(ordinal) -> typ, false, getTimeFormatters(timeZone)))
i += 1
}
TColumn.stringVal(new TStringColumn(values, nulls))
Expand Down

0 comments on commit 37cc70a

Please sign in to comment.