Github user yucai commented on a diff in the pull request:
https://github.com/apache/spark/pull/11212#discussion_r53275413
--- Diff:
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/codegen/UnsafeRowWriter.java
---
@@ -170,6 +170,7 @@ public void write(int ordinal, double value) {
}
public void write(int ordinal, Decimal input, int precision, int scale) {
+ input = input.clone();
--- End diff --
As Adrian mentioned, we need a copy of input, otherwise `changePrecision`
would change the original input.
In our case, this means `catalystValue`(expected value) would be changed
when `checkEvalutionWithUnsafeProjection` is invoked, and then all tests after
checkEvalutionWithUnsafeProjection will fail.
```
protected def checkEvaluation(
expression: => Expression, expected: Any, inputRow: InternalRow =
EmptyRow): Unit = {
val catalystValue = CatalystTypeConverters.convertToCatalyst(expected)
checkEvaluationWithoutCodegen(expression, catalystValue, inputRow)
checkEvaluationWithGeneratedMutableProjection(expression,
catalystValue, inputRow)
if (GenerateUnsafeProjection.canSupport(expression.dataType)) {
checkEvalutionWithUnsafeProjection(expression, catalystValue,
inputRow)
}
checkEvaluationWithOptimization(expression, catalystValue, inputRow)
}
```
Does it make sense? Any suggestion is great helpful.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]