Github user bomeng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12104#discussion_r58268616
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala 
---
    @@ -365,18 +364,20 @@ 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 catalog = sqlContext.sessionState.catalog
    +    val database = db.getOrElse(catalog.getCurrentDatabase)
    +    pattern match {
    +      case Some(p) =>
    +        try {
    +          catalog.listFunctions(database, p).map{f: FunctionIdentifier => 
Row(f.name)}
    +        } catch {
    +          // probably will failed in the regex that user provided, then 
returns empty row.
    +          case _: Throwable => Seq.empty[Row]
    --- End diff --
    
    Is this an over-kill? I think the original code is fine.


---
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]

Reply via email to