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

    https://github.com/apache/spark/pull/6479#discussion_r31687862
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 ---
    @@ -651,41 +677,58 @@ abstract class CodeGenerator[InType <: AnyRef, 
OutType <: AnyRef] extends Loggin
           sys.error(s"Code generation not support for hashset of type 
$unsupportedType")
       }
     
    -  protected def primitiveForType(dt: DataType) = dt match {
    -    case IntegerType => "Int"
    +  protected def primitiveForType(dt: DataType): String = dt match {
    +    case IntegerType => "int"
    +    case LongType => "long"
    +    case ShortType => "short"
    +    case ByteType => "byte"
    +    case DoubleType => "double"
    +    case FloatType => "float"
    +    case BooleanType => "boolean"
    +    case dt @ DecimalType() => "org.apache.spark.sql.types.Decimal"
    +    case BinaryType => "byte[]"
    +    case StringType => "org.apache.spark.sql.types.UTF8String"
    +    case DateType => "int"
    +    case TimestampType => "java.sql.Timestamp"
    +    case _ => "Object"
    +  }
    +
    +  protected def defaultPrimitive(dt: DataType): String = dt match {
    +    case BooleanType => "false"
    +    case FloatType => "-1.0f"
    +    case ShortType => "-1"
    +    case LongType => "-1"
    +    case ByteType => "-1"
    +    case DoubleType => "-1.0"
    +    case IntegerType => "-1"
    +    case DateType => "-1"
    +    case dt @ DecimalType() => "null"
    +    case StringType => "null"
    +    case _ => "null"
    +  }
    +
    +  protected def termForType(dt: DataType): String = dt match {
    +    case IntegerType => "Integer"
         case LongType => "Long"
         case ShortType => "Short"
         case ByteType => "Byte"
         case DoubleType => "Double"
         case FloatType => "Float"
         case BooleanType => "Boolean"
    +    case dt @ DecimalType() => "org.apache.spark.sql.types.Decimal"
    +    case BinaryType => "byte[]"
         case StringType => "org.apache.spark.sql.types.UTF8String"
    -  }
    -
    -  protected def defaultPrimitive(dt: DataType) = dt match {
    -    case BooleanType => ru.Literal(Constant(false))
    -    case FloatType => ru.Literal(Constant(-1.0.toFloat))
    -    case StringType => 
q"""org.apache.spark.sql.types.UTF8String("<uninit>")"""
    -    case ShortType => ru.Literal(Constant(-1.toShort))
    -    case LongType => ru.Literal(Constant(-1L))
    -    case ByteType => ru.Literal(Constant(-1.toByte))
    -    case DoubleType => ru.Literal(Constant(-1.toDouble))
    -    case DecimalType() => q"org.apache.spark.sql.types.Decimal(-1)"
    -    case IntegerType => ru.Literal(Constant(-1))
    -    case DateType => ru.Literal(Constant(-1))
    -    case _ => ru.Literal(Constant(null))
    -  }
    -
    -  protected def termForType(dt: DataType) = dt match {
    -    case n: AtomicType => n.tag
    -    case _ => typeTag[Any]
    +    case DateType => "Integer"
    +    case TimestampType => "java.sql.Timestamp"
    +    case _ =>
    +      "Object"
    --- End diff --
    
    Nit: could go on the same line as the case.


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