Github user kiszk commented on a diff in the pull request: https://github.com/apache/spark/pull/23043#discussion_r233951725 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala --- @@ -56,17 +56,32 @@ case class BoundReference(ordinal: Int, dataType: DataType, nullable: Boolean) val javaType = JavaCode.javaType(dataType) val value = CodeGenerator.getValue(ctx.INPUT_ROW, dataType, ordinal.toString) if (nullable) { - ev.copy(code = + var codeBlock = code""" |boolean ${ev.isNull} = ${ctx.INPUT_ROW}.isNullAt($ordinal); |$javaType ${ev.value} = ${ev.isNull} ? | ${CodeGenerator.defaultValue(dataType)} : ($value); - """.stripMargin) + """.stripMargin + codeBlock = codeBlock + genReplaceMinusZeroWithZeroCode(javaType.codeString, ev.value) + ev.copy(code = codeBlock) } else { - ev.copy(code = code"$javaType ${ev.value} = $value;", isNull = FalseLiteral) + var codeBlock = code"$javaType ${ev.value} = $value;" + codeBlock = codeBlock + genReplaceMinusZeroWithZeroCode(javaType.codeString, ev.value) + ev.copy(code = codeBlock, isNull = FalseLiteral) } } } + + private def genReplaceMinusZeroWithZeroCode(javaType: String, value: String): Block = { + val code = s"\nif ($value == -0.0%c) $value = 0.0%c;" + var formattedCode = "" --- End diff -- ditto
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org