Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/12117#discussion_r58465188
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala
---
@@ -396,18 +400,16 @@ case class ShowFunctions(db: Option[String], pattern:
Option[String]) extends Ru
schema.toAttributes
}
- override def run(sqlContext: SQLContext): Seq[Row] = pattern match {
- case Some(p) =>
- try {
- val regex = java.util.regex.Pattern.compile(p)
- sqlContext.sessionState.functionRegistry.listFunction()
- .filter(regex.matcher(_).matches()).map(Row(_))
- } catch {
- // probably will failed in the regex that user provided, then
returns empty row.
- case _: Throwable => Seq.empty[Row]
- }
- case None =>
- sqlContext.sessionState.functionRegistry.listFunction().map(Row(_))
+ override def run(sqlContext: SQLContext): Seq[Row] = {
+ val dbName =
db.getOrElse(sqlContext.sessionState.catalog.getCurrentDatabase)
+ val functionNames =
+ sqlContext.sessionState.catalog
+ .listFunctions(dbName, pattern.getOrElse(".*"))
+ .map(_.unquotedString)
+ // We use distinct at here because SessionCatalog's listFunctions will
return
+ // duplicated entries for UDFs that have already been loaded into the
--- End diff --
I think more concisely you can say:
```
// The session catalog caches some persistent functions in the temporary
registry
// so there can be duplicates.
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]