Repository: kudu Updated Branches: refs/heads/master ef714838a -> a33e5733c
[tools] Add locate_row support for unsupported key column types BOOL, FLOAT, and DOUBLE are not supported as types for key columns. But there's actually no reason why the tool can't pre-emptively support them in case they are ever permitted as key column types. There's no additional tests because it's not possible to create a table with these types in the primary key. Change-Id: Id1ba6de90feef4c2c565d9033ff442b723a51d7b Reviewed-on: http://gerrit.cloudera.org:8080/11729 Tested-by: Will Berkeley <wdberke...@gmail.com> Reviewed-by: Alexey Serbin <aser...@cloudera.com> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/8a0d1602 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/8a0d1602 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/8a0d1602 Branch: refs/heads/master Commit: 8a0d1602c0097b55e8fc9047bc659397e75f29d3 Parents: ef71483 Author: Will Berkeley <wdberke...@gmail.org> Authored: Thu Oct 18 13:49:38 2018 -0700 Committer: Will Berkeley <wdberke...@gmail.com> Committed: Fri Oct 19 21:28:08 2018 +0000 ---------------------------------------------------------------------- src/kudu/tools/tool_action_table.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/8a0d1602/src/kudu/tools/tool_action_table.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/tool_action_table.cc b/src/kudu/tools/tool_action_table.cc index dbdf31f..097b9b0 100644 --- a/src/kudu/tools/tool_action_table.cc +++ b/src/kudu/tools/tool_action_table.cc @@ -257,6 +257,38 @@ Status LocateRow(const RunnerContext& context) { client::KuduValue::CopyString(value))); break; } + case KuduColumnSchema::BOOL: { + // As of the writing of this tool, BOOL is not a supported key column + // type, but just in case it becomes one, we pre-load support for it. + bool value; + RETURN_NOT_OK_PREPEND( + reader.ExtractBool(values[i], /*field=*/nullptr, &value), + Substitute("unable to parse value for column '$0' of type $1", + col_name, + KuduColumnSchema::DataTypeToString(type))); + predicates.emplace_back( + table->NewComparisonPredicate(col_name, + client::KuduPredicate::EQUAL, + client::KuduValue::FromBool(value))); + break; + } + case KuduColumnSchema::FLOAT: + case KuduColumnSchema::DOUBLE: { + // Like BOOL, as of the writing of this tool, floating point types are + // not supported for key columns, but we can pre-load support for them + // in case they become supported. + double value; + RETURN_NOT_OK_PREPEND( + reader.ExtractDouble(values[i], /*field=*/nullptr, &value), + Substitute("unable to parse value for column '$0' of type $1", + col_name, + KuduColumnSchema::DataTypeToString(type))); + predicates.emplace_back( + table->NewComparisonPredicate(col_name, + client::KuduPredicate::EQUAL, + client::KuduValue::FromDouble(value))); + break; + } case KuduColumnSchema::DECIMAL: return Status::NotSupported( Substitute("unsupported type $0 for key column '$1': "