Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18142#discussion_r119959388
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala
 ---
    @@ -72,39 +89,53 @@ trait FunctionRegistry {
     
     class SimpleFunctionRegistry extends FunctionRegistry {
     
    -  protected val functionBuilders =
    -    StringKeyHashMap[(ExpressionInfo, FunctionBuilder)](caseSensitive = 
false)
    +  @GuardedBy("this")
    +  private val functionBuilders =
    +    new mutable.HashMap[FunctionIdentifier, (ExpressionInfo, 
FunctionBuilder)]
    +
    +  // Resolution of the function name is always case insensitive, but the 
database name
    +  // depends on the caller
    +  private def normalizeFuncName(name: FunctionIdentifier): 
FunctionIdentifier = {
    +    FunctionIdentifier(name.funcName.toLowerCase(Locale.ROOT), 
name.database)
    +  }
     
       override def registerFunction(
    -      name: String,
    +      name: FunctionIdentifier,
           info: ExpressionInfo,
           builder: FunctionBuilder): Unit = synchronized {
    -    functionBuilders.put(name, (info, builder))
    +    functionBuilders.put(normalizeFuncName(name), (info, builder))
       }
     
    -  override def lookupFunction(name: String, children: Seq[Expression]): 
Expression = {
    +  override def lookupFunction(name: FunctionIdentifier, children: 
Seq[Expression]): Expression = {
         val func = synchronized {
    -      functionBuilders.get(name).map(_._2).getOrElse {
    +      functionBuilders.get(normalizeFuncName(name)).map(_._2).getOrElse {
             throw new AnalysisException(s"undefined function $name")
           }
         }
         func(children)
       }
     
    -  override def listFunction(): Seq[String] = synchronized {
    -    functionBuilders.iterator.map(_._1).toList.sorted
    --- End diff --
    
    I think sorted output can make users easy to search for a function, shall 
we still keep it?


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