@@ -232,18 +232,20 @@ case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL"
232
232
}
233
233
234
234
override def inputTypes : Seq [AbstractDataType ] =
235
- Seq (TypeCollection (DoubleType , DecimalType ))
235
+ Seq (TypeCollection (DoubleType , DecimalType , LongType ))
236
236
237
237
protected override def nullSafeEval (input : Any ): Any = child.dataType match {
238
+ case LongType => input.asInstanceOf [Long ]
238
239
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
240
241
}
241
242
242
243
override def doGenCode (ctx : CodegenContext , ev : ExprCode ): ExprCode = {
243
244
child.dataType match {
244
245
case DecimalType .Fixed (_, 0 ) => defineCodeGen(ctx, ev, c => s " $c" )
245
- case DecimalType .Fixed (precision, scale ) =>
246
+ case DecimalType .Fixed (_, _ ) =>
246
247
defineCodeGen(ctx, ev, c => s " $c.ceil() " )
248
+ case LongType => defineCodeGen(ctx, ev, c => s " $c" )
247
249
case _ => defineCodeGen(ctx, ev, c => s " (long)(java.lang.Math. ${funcName}( $c)) " )
248
250
}
249
251
}
@@ -347,18 +349,20 @@ case class Floor(child: Expression) extends UnaryMathExpression(math.floor, "FLO
347
349
}
348
350
349
351
override def inputTypes : Seq [AbstractDataType ] =
350
- Seq (TypeCollection (DoubleType , DecimalType ))
352
+ Seq (TypeCollection (DoubleType , DecimalType , LongType ))
351
353
352
354
protected override def nullSafeEval (input : Any ): Any = child.dataType match {
355
+ case LongType => input.asInstanceOf [Long ]
353
356
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
355
358
}
356
359
357
360
override def doGenCode (ctx : CodegenContext , ev : ExprCode ): ExprCode = {
358
361
child.dataType match {
359
362
case DecimalType .Fixed (_, 0 ) => defineCodeGen(ctx, ev, c => s " $c" )
360
- case DecimalType .Fixed (precision, scale ) =>
363
+ case DecimalType .Fixed (_, _ ) =>
361
364
defineCodeGen(ctx, ev, c => s " $c.floor() " )
365
+ case LongType => defineCodeGen(ctx, ev, c => s " $c" )
362
366
case _ => defineCodeGen(ctx, ev, c => s " (long)(java.lang.Math. ${funcName}( $c)) " )
363
367
}
364
368
}
0 commit comments