Skip to content

Commit c95db44

Browse files
committed
onOperationClosed
1 parent 530758f commit c95db44

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ private[hive] class SparkGetFunctionsOperation(
4949
functionName: String)
5050
extends GetFunctionsOperation(parentSession, catalogName, schemaName, functionName) with Logging {
5151

52+
private var statementId: String = _
53+
54+
override def close(): Unit = {
55+
super.close()
56+
HiveThriftServer2.listener.onOperationClosed(statementId)
57+
}
58+
5259
override def runInternal(): Unit = {
53-
val statementId = UUID.randomUUID().toString
60+
statementId = UUID.randomUUID().toString
5461
// Do not change cmdStr. It's used for Hive auditing and authorization.
5562
val cmdStr = s"catalog : $catalogName, schemaPattern : $schemaName"
5663
val logMsg = s"Listing functions '$cmdStr, functionName : $functionName'"

sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/SparkMetadataOperationSuite.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,19 @@ class SparkMetadataOperationSuite extends HiveThriftJdbcTest {
208208
checkResult(metaData.getFunctions(null, "default", "shift*"),
209209
Seq("shiftleft", "shiftright", "shiftrightunsigned"))
210210
}
211+
212+
withJdbcStatement() { statement =>
213+
val metaData = statement.getConnection.getMetaData
214+
val rs = metaData.getFunctions(null, "default", "upPer")
215+
assert(rs.next())
216+
assert(rs.getString("FUNCTION_SCHEM") === "default")
217+
assert(rs.getString("FUNCTION_NAME") === "upper")
218+
assert(rs.getString("REMARKS") ===
219+
"upper(str) - Returns `str` with all characters changed to uppercase.")
220+
assert(rs.getInt("FUNCTION_TYPE") === DatabaseMetaData.functionResultUnknown)
221+
assert(rs.getString("SPECIFIC_NAME") === "org.apache.spark.sql.catalyst.expressions.Upper")
222+
// Make sure there are no more elements
223+
assert(!rs.next())
224+
}
211225
}
212226
}

0 commit comments

Comments
 (0)