diff --git a/be/src/exec/kudu-util.cc b/be/src/exec/kudu-util.cc index 978b6ea75..2eaebe54c 100644 --- a/be/src/exec/kudu-util.cc +++ b/be/src/exec/kudu-util.cc @@ -112,8 +112,8 @@ Status KuduSchemaFromExpressionList(const std::vector& expressions, RETURN_IF_ERROR(ImpalaToKuduType(node.type, &kt)); // Key columns are not nullable, all others are for now. - bool is_key = key_col_names.find(col_name) == key_col_names.end(); - kudu_cols.push_back(KuduColumnSchema(col_name, kt, is_key)); + bool is_key = key_col_names.find(col_name) != key_col_names.end(); + kudu_cols.push_back(KuduColumnSchema(col_name, kt, !is_key)); } schema->Reset(kudu_cols, std::min(kudu_cols.size(), key_col_names.size())); @@ -151,11 +151,12 @@ Status KuduSchemaFromTupleDescriptor(const TupleDescriptor& tuple_desc, RETURN_IF_ERROR(ImpalaToKuduType(slots[i]->type(), &kt)); // Key columns are not nullable, all others are for now. - bool is_key = key_col_names.find(col_name) == key_col_names.end(); - kudu_cols.push_back(KuduColumnSchema(col_name, kt, is_key)); + bool is_key = key_col_names.find(col_name) != key_col_names.end(); + kudu_cols.push_back(KuduColumnSchema(col_name, kt, !is_key)); } - schema->Reset(kudu_cols, std::min(kudu_cols.size(), key_col_names.size())); + // Scans don't care about key columns so we always pass 0. + schema->Reset(kudu_cols, 0); return Status::OK(); } diff --git a/testdata/workloads/functional-query/queries/QueryTest/kudu-scan-node.test b/testdata/workloads/functional-query/queries/QueryTest/kudu-scan-node.test index 8fe1dd5a4..5e68a2c5d 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/kudu-scan-node.test +++ b/testdata/workloads/functional-query/queries/QueryTest/kudu-scan-node.test @@ -22,4 +22,12 @@ select * from dimtbl order by id limit 1; 1001,'Name1',94611 ---- TYPES BIGINT, STRING, INT +==== +---- QUERY +# Make sure that we can list the columns to be scanned in any order. +select zip, id from dimtbl order by id limit 1; +---- RESULTS +94611,1001 +---- TYPES +INT, BIGINT ==== \ No newline at end of file