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

    https://github.com/apache/spark/pull/14364#discussion_r72565468
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala
 ---
    @@ -452,14 +466,37 @@ object FunctionRegistry {
           }
         }
     
    -    val clazz = tag.runtimeClass
    +    (name, (expressionInfo[T](name), builder))
    +  }
    +
    +  /**
    +   * Creates a function registry lookup entry for cast aliases 
(SPARK-16730).
    +   * For example, if name is "int", and dataType is IntegerType, this 
means int(x) would become
    +   * an alias for cast(x as IntegerType).
    +   * See usage above.
    +   */
    +  private def castAlias(
    +      name: String,
    +      dataType: DataType): (String, (ExpressionInfo, FunctionBuilder)) = {
    +    val builder = (args: Seq[Expression]) => {
    +      if (args.size != 1) {
    +        throw new AnalysisException(s"Function $name accepts only one 
argument")
    +      }
    +      Cast(args.head, dataType)
    +    }
    +    (name, (expressionInfo[Cast](name), builder))
    --- End diff --
    
    Yes - this is a limitation. That's not what Hive does because Hive actually 
does not have a single cast expression. It has a cast expression for each 
target type. I think it's a pretty small detail and fixing it would require a 
lot of work.


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