Skip to content

Commit

Permalink
[SPARK-6134][SQL] Fix wrong datatype for casting FloatType and defaul…
Browse files Browse the repository at this point in the history
…t LongType value in defaultPrimitive

In `CodeGenerator`, the casting on `FloatType` should use `FloatType` instead of `IntegerType`.

Besides, `defaultPrimitive` for `LongType` should be `-1L` instead of `1L`.

Author: Liang-Chi Hsieh <viirya@gmail.com>

Closes #4870 from viirya/codegen_type and squashes the following commits:

76311dd [Liang-Chi Hsieh] Fix wrong datatype for casting on FloatType. Fix the wrong value for LongType in defaultPrimitive.
  • Loading branch information
viirya authored and liancheng committed Mar 4, 2015
1 parent 76b472f commit aef8a84
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
child.castOrNull(c => q"$c.toDouble", DoubleType)

case Cast(child @ NumericType(), FloatType) =>
child.castOrNull(c => q"$c.toFloat", IntegerType)
child.castOrNull(c => q"$c.toFloat", FloatType)

// Special handling required for timestamps in hive test cases since the toString function
// does not match the expected output.
Expand Down Expand Up @@ -626,7 +626,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
case FloatType => ru.Literal(Constant(-1.0.toFloat))
case StringType => ru.Literal(Constant("<uninit>"))
case ShortType => ru.Literal(Constant(-1.toShort))
case LongType => ru.Literal(Constant(1L))
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)"
Expand Down

0 comments on commit aef8a84

Please sign in to comment.