diff options
author | Davies Liu <davies@databricks.com> | 2015-07-01 12:39:57 -0700 |
---|---|---|
committer | Davies Liu <davies@databricks.com> | 2015-07-01 12:39:57 -0700 |
commit | 3083e17645e4b707646fe48e406e02c156a0f37b (patch) | |
tree | 6ff4449e2b311707cae69d745591f3025647b4ac /sql/catalyst/src | |
parent | 9f7db3486fcb403cae8da9dfce8978373c3f47b7 (diff) | |
download | spark-3083e17645e4b707646fe48e406e02c156a0f37b.tar.gz spark-3083e17645e4b707646fe48e406e02c156a0f37b.tar.bz2 spark-3083e17645e4b707646fe48e406e02c156a0f37b.zip |
[QUICKFIX] [SQL] fix copy of generated row
copy() of generated Row doesn't check nullability of columns
Author: Davies Liu <davies@databricks.com>
Closes #7163 from davies/fix_copy and squashes the following commits:
661a206 [Davies Liu] fix copy of generated row
Diffstat (limited to 'sql/catalyst/src')
2 files changed, 4 insertions, 1 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala index 5be47175fa..3c7ee9cc16 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateProjection.scala @@ -148,7 +148,7 @@ object GenerateProjection extends CodeGenerator[Seq[Expression], Projection] { }.mkString("\n") val copyColumns = expressions.zipWithIndex.map { case (e, i) => - s"""arr[$i] = c$i;""" + s"""if (!nullBits[$i]) arr[$i] = c$i;""" }.mkString("\n ") val code = s""" diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala index 7d95ef7f71..3171caf6ad 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala @@ -136,6 +136,9 @@ trait ExpressionEvalHelper { val input = if (inputRow == EmptyRow) "" else s", input: $inputRow" fail(s"Incorrect Evaluation: $expression, actual: $actual, expected: $expected$input") } + if (actual.copy() != expectedRow) { + fail(s"Copy of generated Row is wrong: actual: ${actual.copy()}, expected: $expectedRow") + } } protected def checkEvaluationWithOptimization( |