This is an automated email from the ASF dual-hosted git repository. adar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 80ab2db9fc9ab2ac678333278c2425b7a84a9e63 Author: Todd Lipcon <[email protected]> AuthorDate: Tue Feb 26 16:31:25 2019 -0800 tools: make it easier to scan full rows with 'kudu table scan' This changes the 'table scan' tool so that if --show_values is passed, or if '--columns=*' is specified, the entire row is projected. Previously, the user would have to manually list out all columns of the table, which is somewhat tedious. Change-Id: I89f017baeb0153992ffa0a40b4996a5eb50330f6 Reviewed-on: http://gerrit.cloudera.org:8080/12618 Tested-by: Kudu Jenkins Reviewed-by: Yingchun Lai <[email protected]> Reviewed-by: Grant Henke <[email protected]> --- src/kudu/tools/kudu-tool-test.cc | 15 +++++++++++++-- src/kudu/tools/table_scanner.cc | 8 ++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/kudu/tools/kudu-tool-test.cc b/src/kudu/tools/kudu-tool-test.cc index d7b864f..d282349 100644 --- a/src/kudu/tools/kudu-tool-test.cc +++ b/src/kudu/tools/kudu-tool-test.cc @@ -413,14 +413,25 @@ class ToolTest : public KuduTest { cluster_->master()->bound_rpc_addr().ToString(), table_name, projection, predicates_json), &lines)); + + vector<pair<string, string>> expected_columns; + if (columns.empty()) { + // If we ran with an empty projection, we'll actually get all the columns. + expected_columns = {{ "int32", "key" }, + { "int32", "int_val" }, + { "string", "string_val" }}; + } else { + expected_columns = columns; + } + size_t line_count = 0; int64_t value = min_value; for (const auto& line : lines) { if (line.find('(') != string::npos) { // Check matched rows. vector<string> kvs; - kvs.reserve(columns.size()); - for (const auto& column : columns) { + kvs.reserve(expected_columns.size()); + for (const auto& column : expected_columns) { // Check projected columns. kvs.push_back(Substitute("$0 $1=$2", column.first, column.second, column.second == "key" ? to_string(value) : ".*")); diff --git a/src/kudu/tools/table_scanner.cc b/src/kudu/tools/table_scanner.cc index 9ed6e16..bd87902 100644 --- a/src/kudu/tools/table_scanner.cc +++ b/src/kudu/tools/table_scanner.cc @@ -566,8 +566,12 @@ Status TableScanner::StartWork(WorkType type) { // Set projection if needed. if (type == WorkType::kScan) { - vector<string> projected_column_names = Split(FLAGS_columns, ",", strings::SkipEmpty()); - RETURN_NOT_OK(builder.SetProjectedColumnNames(projected_column_names)); + bool project_all = FLAGS_columns == "*" || + (FLAGS_show_values && FLAGS_columns.empty()); + if (!project_all) { + vector<string> projected_column_names = Split(FLAGS_columns, ",", strings::SkipEmpty()); + RETURN_NOT_OK(builder.SetProjectedColumnNames(projected_column_names)); + } } // Set predicates.
