maropu commented on issue #26599: [SPARK-29961][SQL] Implement builtin function 
- typeof
URL: https://github.com/apache/spark/pull/26599#issuecomment-555893986
 
 
   > We've marked UDT as interval API, I don't think we need to support it in 
the end-user function.
   
   Yea, I also think we don't need to support it. But, if we don't support it, 
I think we need to define `checkInputDataTypes` for `typeof`. Actually, it 
seems this pr hits weird exceptions for the type;
   
   ```
   scala> sql("select * from t").show()
   +---+-------------+
   | id|       vector|
   +---+-------------+
   |  a|[1.0,2.0,3.0]|
   |  b|[4.0,5.0,6.0]|
   +---+-------------+
   
   
   scala> sql("select * from t").printSchema
   root
    |-- id: string (nullable = true)
    |-- vector: vector (nullable = true)
   
   
   scala> sql("select typeof(vector) from t").show()
   java.lang.ClassCastException: java.lang.String cannot be cast to 
org.apache.spark.unsafe.types.UTF8String
     at 
org.apache.spark.sql.catalyst.InternalRow$.$anonfun$getWriter$10(InternalRow.scala:176)
     at 
org.apache.spark.sql.catalyst.InternalRow$.$anonfun$getWriter$10$adapted(InternalRow.scala:176)
     at 
org.apache.spark.sql.catalyst.expressions.InterpretedMutableProjection.$anonfun$fieldWriters$2(InterpretedMutableProjection.scala:66)
     at 
org.apache.spark.sql.catalyst.expressions.InterpretedMutableProjection.$anonfun$fieldWriters$2$adapted(InterpretedMutableProjection.scala:66)
     at 
org.apache.spark.sql.catalyst.expressions.InterpretedMutableProjection.apply(InterpretedMutableProjection.scala:89)
     at 
org.apache.spark.sql.catalyst.optimizer.ConvertToLocalRelation$$anonfun$apply$17.$anonfun$applyOrElse$71(Optimizer.scala:1502)
     at 
scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
     at scala.collection.immutable.List.foreach(List.scala:392)
     at scala.collection.TraversableLike.map(TraversableLike.scal
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to