@@ -232,18 +232,20 @@ case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL"
232232 }
233233
234234 override def inputTypes : Seq [AbstractDataType ] =
235- Seq (TypeCollection (DoubleType , DecimalType ))
235+ Seq (TypeCollection (DoubleType , DecimalType , LongType ))
236236
237237 protected override def nullSafeEval (input : Any ): Any = child.dataType match {
238+ case LongType => input.asInstanceOf [Long ]
238239 case DoubleType => f(input.asInstanceOf [Double ]).toLong
239- case DecimalType .Fixed (precision, scale ) => input.asInstanceOf [Decimal ].ceil
240+ case DecimalType .Fixed (_, _ ) => input.asInstanceOf [Decimal ].ceil
240241 }
241242
242243 override def doGenCode (ctx : CodegenContext , ev : ExprCode ): ExprCode = {
243244 child.dataType match {
244245 case DecimalType .Fixed (_, 0 ) => defineCodeGen(ctx, ev, c => s " $c" )
245- case DecimalType .Fixed (precision, scale ) =>
246+ case DecimalType .Fixed (_, _ ) =>
246247 defineCodeGen(ctx, ev, c => s " $c.ceil() " )
248+ case LongType => defineCodeGen(ctx, ev, c => s " $c" )
247249 case _ => defineCodeGen(ctx, ev, c => s " (long)(java.lang.Math. ${funcName}( $c)) " )
248250 }
249251 }
@@ -347,18 +349,20 @@ case class Floor(child: Expression) extends UnaryMathExpression(math.floor, "FLO
347349 }
348350
349351 override def inputTypes : Seq [AbstractDataType ] =
350- Seq (TypeCollection (DoubleType , DecimalType ))
352+ Seq (TypeCollection (DoubleType , DecimalType , LongType ))
351353
352354 protected override def nullSafeEval (input : Any ): Any = child.dataType match {
355+ case LongType => input.asInstanceOf [Long ]
353356 case DoubleType => f(input.asInstanceOf [Double ]).toLong
354- case DecimalType .Fixed (precision, scale ) => input.asInstanceOf [Decimal ].floor
357+ case DecimalType .Fixed (_, _ ) => input.asInstanceOf [Decimal ].floor
355358 }
356359
357360 override def doGenCode (ctx : CodegenContext , ev : ExprCode ): ExprCode = {
358361 child.dataType match {
359362 case DecimalType .Fixed (_, 0 ) => defineCodeGen(ctx, ev, c => s " $c" )
360- case DecimalType .Fixed (precision, scale ) =>
363+ case DecimalType .Fixed (_, _ ) =>
361364 defineCodeGen(ctx, ev, c => s " $c.floor() " )
365+ case LongType => defineCodeGen(ctx, ev, c => s " $c" )
362366 case _ => defineCodeGen(ctx, ev, c => s " (long)(java.lang.Math. ${funcName}( $c)) " )
363367 }
364368 }
0 commit comments