aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src
diff options
context:
space:
mode:
authorSameer Agarwal <sameer@databricks.com>2016-04-24 22:52:50 -0700
committerDavies Liu <davies.liu@gmail.com>2016-04-24 22:52:50 -0700
commitcbdcd4edab48593f6331bc267eb94e40908733e5 (patch)
tree400cba8511ec4273b73247d2ce9a9fc433e88cfa /sql/catalyst/src
parentc752b6c5ec488b87c3aaaa86902dd4da9b4b406f (diff)
downloadspark-cbdcd4edab48593f6331bc267eb94e40908733e5.tar.gz
spark-cbdcd4edab48593f6331bc267eb94e40908733e5.tar.bz2
spark-cbdcd4edab48593f6331bc267eb94e40908733e5.zip
[SPARK-14870] [SQL] Fix NPE in TPCDS q14a
## What changes were proposed in this pull request? This PR fixes a bug in `TungstenAggregate` that manifests while aggregating by keys over nullable `BigDecimal` columns. This causes a null pointer exception while executing TPCDS q14a. ## How was this patch tested? 1. Added regression test in `DataFrameAggregateSuite`. 2. Verified that TPCDS q14a works Author: Sameer Agarwal <sameer@databricks.com> Closes #12651 from sameeragarwal/tpcds-fix.
Diffstat (limited to 'sql/catalyst/src')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
index fa09f821fc..e4fa429b37 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
@@ -239,16 +239,19 @@ class CodegenContext {
/**
* Update a column in MutableRow from ExprCode.
+ *
+ * @param isVectorized True if the underlying row is of type `ColumnarBatch.Row`, false otherwise
*/
def updateColumn(
row: String,
dataType: DataType,
ordinal: Int,
ev: ExprCode,
- nullable: Boolean): String = {
+ nullable: Boolean,
+ isVectorized: Boolean = false): String = {
if (nullable) {
// Can't call setNullAt on DecimalType, because we need to keep the offset
- if (dataType.isInstanceOf[DecimalType]) {
+ if (!isVectorized && dataType.isInstanceOf[DecimalType]) {
s"""
if (!${ev.isNull}) {
${setColumn(row, dataType, ordinal, ev.value)};