Skip to content

Commit 4aa2dd2

Browse files
committed
address comment
1 parent 2acb51a commit 4aa2dd2

File tree

8 files changed

+81
-65
lines changed

8 files changed

+81
-65
lines changed

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,16 @@ private[hive] class SparkExecuteStatementOperation(
282282
} else {
283283
logError(s"Error executing query with $statementId, currentState $currentState, ", e)
284284
setState(OperationState.ERROR)
285-
HiveThriftServer2.listener.onStatementError(
286-
statementId, e.getMessage, SparkUtils.exceptionString(e))
287-
if (e.isInstanceOf[HiveSQLException]) {
288-
throw e.asInstanceOf[HiveSQLException]
289-
} else {
290-
val root = ExceptionUtils.getRootCause(e)
291-
throw new HiveSQLException("Error running query: " +
292-
(if (root == null) e.toString else root.toString), e)
285+
e match {
286+
case hiveException: HiveSQLException =>
287+
HiveThriftServer2.listener.onStatementError(
288+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
289+
throw hiveException
290+
case _ =>
291+
val root = ExceptionUtils.getRootCause(e)
292+
HiveThriftServer2.listener.onStatementError(
293+
statementId, root.getMessage, SparkUtils.exceptionString(root))
294+
throw new HiveSQLException("Error running query: " + root.toString, root)
293295
}
294296
}
295297
} finally {

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetCatalogsOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ private[hive] class SparkGetCatalogsOperation(
7272
case e: Throwable =>
7373
logError(s"Error executing get catalogs operation with $statementId", e)
7474
setState(OperationState.ERROR)
75-
HiveThriftServer2.listener.onStatementError(
76-
statementId, e.getMessage, SparkUtils.exceptionString(e))
77-
if (e.isInstanceOf[HiveSQLException]) {
78-
throw e.asInstanceOf[HiveSQLException]
79-
} else {
80-
val root = ExceptionUtils.getRootCause(e)
81-
throw new HiveSQLException("Error getting catalogs: " +
82-
(if (root == null) e.toString else root.toString), e)
75+
e match {
76+
case hiveException: HiveSQLException =>
77+
HiveThriftServer2.listener.onStatementError(
78+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
79+
throw hiveException
80+
case _ =>
81+
val root = ExceptionUtils.getRootCause(e)
82+
HiveThriftServer2.listener.onStatementError(
83+
statementId, root.getMessage, SparkUtils.exceptionString(root))
84+
throw new HiveSQLException("Error getting catalogs: " + root.toString, root)
8385
}
8486
}
8587
HiveThriftServer2.listener.onStatementFinish(statementId)

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetColumnsOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ private[hive] class SparkGetColumnsOperation(
133133
case e: Throwable =>
134134
logError(s"Error executing get columns operation with $statementId", e)
135135
setState(OperationState.ERROR)
136-
HiveThriftServer2.listener.onStatementError(
137-
statementId, e.getMessage, SparkUtils.exceptionString(e))
138-
if (e.isInstanceOf[HiveSQLException]) {
139-
throw e.asInstanceOf[HiveSQLException]
140-
} else {
141-
val root = ExceptionUtils.getRootCause(e)
142-
throw new HiveSQLException("Error getting columns: " +
143-
(if (root == null) e.toString else root.toString), e)
136+
e match {
137+
case hiveException: HiveSQLException =>
138+
HiveThriftServer2.listener.onStatementError(
139+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
140+
throw hiveException
141+
case _ =>
142+
val root = ExceptionUtils.getRootCause(e)
143+
HiveThriftServer2.listener.onStatementError(
144+
statementId, root.getMessage, SparkUtils.exceptionString(root))
145+
throw new HiveSQLException("Error getting columns: " + root.toString, root)
144146
}
145147
}
146148
HiveThriftServer2.listener.onStatementFinish(statementId)

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetFunctionsOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@ private[hive] class SparkGetFunctionsOperation(
108108
case e: Throwable =>
109109
logError(s"Error executing get functions operation with $statementId", e)
110110
setState(OperationState.ERROR)
111-
HiveThriftServer2.listener.onStatementError(
112-
statementId, e.getMessage, SparkUtils.exceptionString(e))
113-
if (e.isInstanceOf[HiveSQLException]) {
114-
throw e.asInstanceOf[HiveSQLException]
115-
} else {
116-
val root = ExceptionUtils.getRootCause(e)
117-
throw new HiveSQLException("Error getting functions: " +
118-
(if (root == null) e.toString else root.toString), e)
111+
e match {
112+
case hiveException: HiveSQLException =>
113+
HiveThriftServer2.listener.onStatementError(
114+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
115+
throw hiveException
116+
case _ =>
117+
val root = ExceptionUtils.getRootCause(e)
118+
HiveThriftServer2.listener.onStatementError(
119+
statementId, root.getMessage, SparkUtils.exceptionString(root))
120+
throw new HiveSQLException("Error getting functions: " + root.toString, root)
119121
}
120122
}
121123
HiveThriftServer2.listener.onStatementFinish(statementId)

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetSchemasOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ private[hive] class SparkGetSchemasOperation(
9191
case e: Throwable =>
9292
logError(s"Error executing get schemas operation with $statementId", e)
9393
setState(OperationState.ERROR)
94-
HiveThriftServer2.listener.onStatementError(
95-
statementId, e.getMessage, SparkUtils.exceptionString(e))
96-
if (e.isInstanceOf[HiveSQLException]) {
97-
throw e.asInstanceOf[HiveSQLException]
98-
} else {
99-
val root = ExceptionUtils.getRootCause(e)
100-
throw new HiveSQLException("Error getting schemas: " +
101-
(if (root == null) e.toString else root.toString), e)
94+
e match {
95+
case hiveException: HiveSQLException =>
96+
HiveThriftServer2.listener.onStatementError(
97+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
98+
throw hiveException
99+
case _ =>
100+
val root = ExceptionUtils.getRootCause(e)
101+
HiveThriftServer2.listener.onStatementError(
102+
statementId, root.getMessage, SparkUtils.exceptionString(root))
103+
throw new HiveSQLException("Error getting schemas: " + root.toString, root)
102104
}
103105
}
104106
HiveThriftServer2.listener.onStatementFinish(statementId)

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetTableTypesOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ private[hive] class SparkGetTableTypesOperation(
7878
case e: Throwable =>
7979
logError(s"Error executing get table types operation with $statementId", e)
8080
setState(OperationState.ERROR)
81-
HiveThriftServer2.listener.onStatementError(
82-
statementId, e.getMessage, SparkUtils.exceptionString(e))
83-
if (e.isInstanceOf[HiveSQLException]) {
84-
throw e.asInstanceOf[HiveSQLException]
85-
} else {
86-
val root = ExceptionUtils.getRootCause(e)
87-
throw new HiveSQLException("Error getting table types: " +
88-
(if (root == null) e.toString else root.toString), e)
81+
e match {
82+
case hiveException: HiveSQLException =>
83+
HiveThriftServer2.listener.onStatementError(
84+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
85+
throw hiveException
86+
case _ =>
87+
val root = ExceptionUtils.getRootCause(e)
88+
HiveThriftServer2.listener.onStatementError(
89+
statementId, root.getMessage, SparkUtils.exceptionString(root))
90+
throw new HiveSQLException("Error getting table types: " + root.toString, root)
8991
}
9092
}
9193
HiveThriftServer2.listener.onStatementFinish(statementId)

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetTablesOperation.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,16 @@ private[hive] class SparkGetTablesOperation(
122122
case e: Throwable =>
123123
logError(s"Error executing get tables operation with $statementId", e)
124124
setState(OperationState.ERROR)
125-
HiveThriftServer2.listener.onStatementError(
126-
statementId, e.getMessage, SparkUtils.exceptionString(e))
127-
if (e.isInstanceOf[HiveSQLException]) {
128-
throw e.asInstanceOf[HiveSQLException]
129-
} else {
130-
val root = ExceptionUtils.getRootCause(e)
131-
throw new HiveSQLException("Error getting tables: " +
132-
(if (root == null) e.toString else root.toString), e)
125+
e match {
126+
case hiveException: HiveSQLException =>
127+
HiveThriftServer2.listener.onStatementError(
128+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
129+
throw hiveException
130+
case _ =>
131+
val root = ExceptionUtils.getRootCause(e)
132+
HiveThriftServer2.listener.onStatementError(
133+
statementId, root.getMessage, SparkUtils.exceptionString(root))
134+
throw new HiveSQLException("Error getting tables: " + root.toString, root)
133135
}
134136
}
135137
HiveThriftServer2.listener.onStatementFinish(statementId)

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetTypeInfoOperation.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,18 @@ private[hive] class SparkGetTypeInfoOperation(
9494
setState(OperationState.FINISHED)
9595
} catch {
9696
case e: Throwable =>
97-
logError(s"Error executing get table types type info with $statementId", e)
97+
logError(s"Error executing get type info with $statementId", e)
9898
setState(OperationState.ERROR)
99-
HiveThriftServer2.listener.onStatementError(
100-
statementId, e.getMessage, SparkUtils.exceptionString(e))
101-
if (e.isInstanceOf[HiveSQLException]) {
102-
throw e.asInstanceOf[HiveSQLException]
103-
} else {
104-
val root = ExceptionUtils.getRootCause(e)
105-
throw new HiveSQLException("Error getting type info: " +
106-
(if (root == null) e.toString else root.toString), e)
99+
e match {
100+
case hiveException: HiveSQLException =>
101+
HiveThriftServer2.listener.onStatementError(
102+
statementId, hiveException.getMessage, SparkUtils.exceptionString(hiveException))
103+
throw hiveException
104+
case _ =>
105+
val root = ExceptionUtils.getRootCause(e)
106+
HiveThriftServer2.listener.onStatementError(
107+
statementId, root.getMessage, SparkUtils.exceptionString(root))
108+
throw new HiveSQLException("Error getting type info: " + root.toString, root)
107109
}
108110
}
109111
HiveThriftServer2.listener.onStatementFinish(statementId)

0 commit comments

Comments
 (0)