[GitHub] [spark] maropu commented on a change in pull request #30372: [SPARK-33172][SQL] Adding support for UserDefinedType for Spark SQL Code generator

2020-11-16 Thread GitBox


maropu commented on a change in pull request #30372:
URL: https://github.com/apache/spark/pull/30372#discussion_r524941668



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
##
@@ -1734,15 +1734,17 @@ object CodeGenerator extends Logging {
* Returns the specialized code to access a value from a column vector for a 
given `DataType`.
*/
   def getValueFromVector(vector: String, dataType: DataType, rowId: String): 
String = {
-if (dataType.isInstanceOf[StructType]) {
-  // `ColumnVector.getStruct` is different from `InternalRow.getStruct`, 
it only takes an
-  // `ordinal` parameter.
-  s"$vector.getStruct($rowId)"
-} else {
-  getValue(vector, dataType, rowId)
+dataType match {
+  case udt: UserDefinedType[_] => getValueFromVector(vector, udt.sqlType, 
rowId)
+  case _ => if (dataType.isInstanceOf[StructType]) {
+// `ColumnVector.getStruct` is different from `InternalRow.getStruct`, 
it only takes an
+// `ordinal` parameter.
+s"$vector.getStruct($rowId)"
+  } else {
+getValue(vector, dataType, rowId)
+  }
 }
   }
-

Review comment:
   nit: revert this (unnecessary change)





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] maropu commented on a change in pull request #30372: [SPARK-33172][SQL] Adding support for UserDefinedType for Spark SQL Code generator

2020-11-16 Thread GitBox


maropu commented on a change in pull request #30372:
URL: https://github.com/apache/spark/pull/30372#discussion_r524941488



##
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
##
@@ -1734,15 +1734,17 @@ object CodeGenerator extends Logging {
* Returns the specialized code to access a value from a column vector for a 
given `DataType`.
*/
   def getValueFromVector(vector: String, dataType: DataType, rowId: String): 
String = {
-if (dataType.isInstanceOf[StructType]) {
-  // `ColumnVector.getStruct` is different from `InternalRow.getStruct`, 
it only takes an
-  // `ordinal` parameter.
-  s"$vector.getStruct($rowId)"
-} else {
-  getValue(vector, dataType, rowId)
+dataType match {
+  case udt: UserDefinedType[_] => getValueFromVector(vector, udt.sqlType, 
rowId)

Review comment:
   Does this issue only happens when using 
`spark-bigquery-with-dependencies`? In the current spark codebase, it seems 
dataType cannot be an user-defined type in this method.





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:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org