Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/13976 )
Change subject: [tools] Add table tools to delete column and alter column ...................................................................... Patch Set 4: (5 comments) http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/client/schema.cc File src/kudu/client/schema.cc: http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/client/schema.cc@720 PS4, Line 720: : KuduColumnSchema KuduSchema::Column(const std::string& col_name) const { : int idx = schema_->find_column(col_name); : DCHECK_NE(idx, Schema::kColumnNotFound); : return Column(idx); : } Hitting a CHECK or DCHECK as a user is pretty unpleasant. It's a better user experience if the tool were to catch errors and return a message about why it failed. Maybe consider having this be: bool KuduSchema::Column(const std::string& col_name, KuduColumnSchema* col) { int idx = schema_->find_column(col_name); if (idx == kColumnNotFound) { return false; } *col = Column(idx); return true; } and catching errors when calling this function. http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/tools/tool_action_table.cc File src/kudu/tools/tool_action_table.cc: http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/tools/tool_action_table.cc@183 PS4, Line 183: ADD, : DROP, nit: not from this patch, but could you reduce the indent here by two spaces? http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/tools/tool_action_table.cc@710 PS4, Line 710: CHECK(false) << Substitute("Unhandled type $0", type); Why aren't other types (e.g. bool, binary, decimal) represented here? Also, could you have this return a Status instead of hitting a check failure? We try to use CHECKs to indicate a programmer error, rather than a user error. We could also then return Status::InvalidArgument() instead of nullptr in cases where the values aren't correct. I would recommend combining this function with ParseSetDefaultArgs() as: Status ParseArgOfType(const std::string& arg, KuduColumnSchema::DataType type, KuduValue* value) { // Switch on the type // If the value doesn't match the type, return Status::InvalidArgument() ... return Status::OK(); } http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/tools/tool_action_table.cc@732 PS4, Line 732: if (encoding_type_uc == "AUTO_ENCODING") { : *encoding_type = KuduColumnStorageAttributes::EncodingType::AUTO_ENCODING; : } else if (encoding_type_uc == "PLAIN_ENCODING") { : *encoding_type = KuduColumnStorageAttributes::EncodingType::PLAIN_ENCODING; : } else if (encoding_type_uc == "PREFIX_ENCODING") { : *encoding_type = KuduColumnStorageAttributes::EncodingType::PREFIX_ENCODING; : } else if (encoding_type_uc == "RLE") { : *encoding_type = KuduColumnStorageAttributes::EncodingType::RLE; : } else if (encoding_type_uc == "DICT_ENCODING") { : *encoding_type = KuduColumnStorageAttributes::EncodingType::DICT_ENCODING; : } else if (encoding_type_uc == "BIT_SHUFFLE") { : *encoding_type = KuduColumnStorageAttributes::EncodingType::BIT_SHUFFLE; What do you think about storing these in a map of { string => KuduColumnStorageAttributes::EncodingType } and iterating through that map? We could also reuse that map to print out a useful error message, like "Failed to parse encoding type from <arg>, supported encoding types: <encoding types>". http://gerrit.cloudera.org:8080/#/c/13976/4/src/kudu/tools/tool_action_table.cc@810 PS4, Line 810: atoi32(FLAGS_alter_args) Should we check that the input here is valid? -- To view, visit http://gerrit.cloudera.org:8080/13976 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: kudu Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I228340e46fe48ffc782c4c7346f890444b8c550f Gerrit-Change-Number: 13976 Gerrit-PatchSet: 4 Gerrit-Owner: Yifan Zhang <[email protected]> Gerrit-Reviewer: Andrew Wong <[email protected]> Gerrit-Reviewer: Kudu Jenkins (120) Gerrit-Reviewer: Tidy Bot (241) Gerrit-Reviewer: Yifan Zhang <[email protected]> Gerrit-Reviewer: Yingchun Lai <[email protected]> Gerrit-Comment-Date: Fri, 02 Aug 2019 03:04:16 +0000 Gerrit-HasComments: Yes
