Skip to content

Commit 76311dd

Browse files
committed
Fix wrong datatype for casting on FloatType. Fix the wrong value for LongType in defaultPrimitive.
1 parent 3efd8bb commit 76311dd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
259259
child.castOrNull(c => q"$c.toDouble", DoubleType)
260260

261261
case Cast(child @ NumericType(), FloatType) =>
262-
child.castOrNull(c => q"$c.toFloat", IntegerType)
262+
child.castOrNull(c => q"$c.toFloat", FloatType)
263263

264264
// Special handling required for timestamps in hive test cases since the toString function
265265
// does not match the expected output.
@@ -626,7 +626,7 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
626626
case FloatType => ru.Literal(Constant(-1.0.toFloat))
627627
case StringType => ru.Literal(Constant("<uninit>"))
628628
case ShortType => ru.Literal(Constant(-1.toShort))
629-
case LongType => ru.Literal(Constant(1L))
629+
case LongType => ru.Literal(Constant(-1L))
630630
case ByteType => ru.Literal(Constant(-1.toByte))
631631
case DoubleType => ru.Literal(Constant(-1.toDouble))
632632
case DecimalType() => q"org.apache.spark.sql.types.Decimal(-1)"

0 commit comments

Comments
 (0)