IMPALA-5217: KuduTableSink checks null constraints incorrectly

KuduTableSink uses the referenced_columns map to translate between the
index into the output exprs 'j' and the index into columns in the Kudu
table 'col', but we incorrectly use 'j' when calling into the Kudu table
schema to check the nullability of columns.

Testing:
- Added e2e tests to kudu_insert.test

Change-Id: I8ed458278f135288a821570939de8ee294183df2
Reviewed-on: http://gerrit.cloudera.org:8080/6670
Reviewed-by: Thomas Tauber-Marshall <[email protected]>
Tested-by: Impala Public Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/baba8960
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/baba8960
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/baba8960

Branch: refs/heads/master
Commit: baba8960b3cdb167f4eaa300559813c5cea2786d
Parents: 2a34076
Author: Thomas Tauber-Marshall <[email protected]>
Authored: Tue Apr 18 11:29:51 2017 -0700
Committer: Impala Public Jenkins <[email protected]>
Committed: Thu Apr 20 23:27:59 2017 +0000

----------------------------------------------------------------------
 be/src/exec/kudu-table-sink.cc                  |  2 +-
 .../queries/QueryTest/kudu_insert.test          | 28 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/baba8960/be/src/exec/kudu-table-sink.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/kudu-table-sink.cc b/be/src/exec/kudu-table-sink.cc
index 699f00a..9b0085c 100644
--- a/be/src/exec/kudu-table-sink.cc
+++ b/be/src/exec/kudu-table-sink.cc
@@ -234,7 +234,7 @@ Status KuduTableSink::Send(RuntimeState* state, RowBatch* 
batch) {
 
       void* value = output_expr_ctxs_[j]->GetValue(current_row);
       if (value == NULL) {
-        if (table_schema.Column(j).is_nullable()) {
+        if (table_schema.Column(col).is_nullable()) {
           KUDU_RETURN_IF_ERROR(write->mutable_row()->SetNull(col),
               "Could not add Kudu WriteOp.");
           continue;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/baba8960/testdata/workloads/functional-query/queries/QueryTest/kudu_insert.test
----------------------------------------------------------------------
diff --git 
a/testdata/workloads/functional-query/queries/QueryTest/kudu_insert.test 
b/testdata/workloads/functional-query/queries/QueryTest/kudu_insert.test
index a61e226..f2b12b1 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/kudu_insert.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/kudu_insert.test
@@ -402,3 +402,31 @@ A, B, C, D, E, F, G, H, I, J
 ---- TYPES
 INT,INT,INT,INT,INT,INT,STRING,BOOLEAN,INT,INT
 ====
+---- QUERY
+# IMPALA-5217: Try to insert NULL to a 'NOT NULL' col with a target col list 
that leaves
+# out some cols.
+insert into tbl_with_defaults (a, c, f) values (0, null, 1)
+---- RUNTIME_PROFILE
+NumModifiedRows: 0
+NumRowErrors: 1
+====
+---- QUERY
+# IMPALA-5217: Insert NULL into a nullable col when a non-nullable col has 
been left out
+# of the target col list.
+insert into tbl_with_defaults (a, b, d, f) values (0, 0, null, 0)
+---- RUNTIME_PROFILE
+NumModifiedRows: 1
+NumRowErrors: 0
+---- LABELS
+A, B, C, D, E, F, G, H, I, J
+---- DML_RESULTS: tbl_with_defaults
+0,0,100,NULL,NULL,0,'test',true,NULL,10000
+1,10,100,1000,NULL,1,'test',true,NULL,10000
+2,10,100,1000,NULL,2,'test',true,NULL,10000
+3,10,100,1000,NULL,3,'test',true,NULL,10000
+4,10,100,1000,NULL,4,'test',true,NULL,10000
+5,5,5,5,5,5,'row',false,NULL,10000
+6,6,6,6,6,6,'another row',false,6,6
+---- TYPES
+INT,INT,INT,INT,INT,INT,STRING,BOOLEAN,INT,INT
+====

Reply via email to