Skip to content

Commit 196f7ce

Browse files
author
Andrew Or
committed
Document and clean up function methods
1 parent 6d530a9 commit 196f7ce

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,23 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
220220
// | Methods that interact with metastore functions only |
221221
// -------------------------------------------------------
222222

223+
/**
224+
* Create a metastore function in the database specified in `funcDefinition`.
225+
* If no such database is specified, create it in the current database.
226+
*/
223227
def createFunction(currentDb: String, funcDefinition: CatalogFunction): Unit
224228

229+
/**
230+
* Drop a metastore function.
231+
* If no database is specified, assume the function is in the current database.
232+
*/
225233
def dropFunction(currentDb: String, funcName: FunctionIdentifier): Unit
226234

227235
/**
228-
* Alter a function whose name that matches the one specified in `funcDefinition`,
229-
* assuming the function exists.
236+
* Alter a function whose name that matches the one specified in `funcDefinition`.
237+
*
238+
* If no database is specified in `funcDefinition`, assume the function is in the
239+
* current database.
230240
*
231241
* Note: If the underlying implementation does not support altering a certain field,
232242
* this becomes a no-op.
@@ -237,20 +247,43 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
237247
// | Methods that interact with temporary and metastore functions |
238248
// ----------------------------------------------------------------
239249

250+
/**
251+
* Create a temporary function.
252+
* This assumes no database is specified in `funcDefinition`.
253+
*/
240254
def createTempFunction(funcDefinition: CatalogFunction): Unit
241255

242256
// TODO: The reason that we distinguish dropFunction and dropTempFunction is that
243257
// Hive has DROP FUNCTION and DROP TEMPORARY FUNCTION. We may want to consolidate
244258
// dropFunction and dropTempFunction.
245-
def dropTempFunction(funcName: String): Unit
259+
def dropTempFunction(name: String): Unit
246260

261+
/**
262+
* Rename a function.
263+
*
264+
* If a database is specified in `oldName`, this will rename the function in that database.
265+
* If no database is specified, this will first attempt to rename a temporary function with
266+
* the same name, then, if that does not exist, rename the function in the current database.
267+
*
268+
* This assumes the database specified in `oldName` matches the one specified in `newName`.
269+
*/
247270
def renameFunction(
248271
currentDb: String,
249272
oldName: FunctionIdentifier,
250273
newName: FunctionIdentifier): Unit
251274

252-
def getFunction(currentDb: String, funcIdentifier: FunctionIdentifier): CatalogFunction
275+
/**
276+
* Retrieve the metadata of an existing function.
277+
*
278+
* If a database is specified in `name`, this will return the function in that database.
279+
* If no database is specified, this will first attempt to return a temporary function with
280+
* the same name, then, if that does not exist, return the function in the current database.
281+
*/
282+
def getFunction(currentDb: String, name: FunctionIdentifier): CatalogFunction
253283

284+
/**
285+
* List all matching functions in the current database, including temporary functions.
286+
*/
254287
def listFunctions(currentDb: String, pattern: String): Seq[FunctionIdentifier]
255288

256289
}

0 commit comments

Comments
 (0)