cloud-fan commented on code in PR #36698:
URL: https://github.com/apache/spark/pull/36698#discussion_r885424345
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala:
##########
@@ -778,16 +999,26 @@ case class Pmod(
val javaType = CodeGenerator.javaType(dataType)
lazy val errorContext = ctx.addReferenceObj("errCtx", queryContext)
val result = dataType match {
- case DecimalType.Fixed(_, _) =>
+ case DecimalType.Fixed(precision, scale) =>
+ val errorContextCode = if (nullOnOverflow) {
+ "\"\""
+ } else {
+ errorContext
+ }
+ val value = ctx.freshName("value")
val decimalAdd = "$plus"
s"""
- $javaType $remainder = ${eval1.value}.remainder(${eval2.value});
- if ($remainder.compare(new
org.apache.spark.sql.types.Decimal().set(0)) < 0) {
-
${ev.value}=($remainder.$decimalAdd(${eval2.value})).remainder(${eval2.value});
- } else {
- ${ev.value}=$remainder;
- }
- """
+ |$javaType $value = ${CodeGenerator.defaultValue(dataType)};
Review Comment:
We can directly use `${ev.value}` here, and assign it again later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]