kou commented on code in PR #41995:
URL: https://github.com/apache/arrow/pull/41995#discussion_r1628587875


##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -411,21 +409,23 @@ bool InputType::Matches(const DataType& type) const {
       return type_->Equals(type);
     case InputType::USE_TYPE_MATCHER:
       return type_matcher_->Matches(type);
-    default:
-      // ANY_TYPE
-      return true;
+    case InputType::ANY_TYPE:
+      break;

Review Comment:
   It's not a strong opinion but I like using `return true` here for 
consistency of other `case`s in this `switch`:
   
   ```suggestion
         return true;
   ```



##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -400,9 +399,8 @@ bool InputType::Equals(const InputType& other) const {
       return type_->Equals(*other.type_);
     case InputType::USE_TYPE_MATCHER:
       return type_matcher_->Equals(*other.type_matcher_);
-    default:
-      return false;
   }
+  return false;

Review Comment:
   Can we add a comment about "must not be reached" or something here?



##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -463,11 +465,13 @@ const OutputType::Resolver& OutputType::resolver() const {
 }
 
 std::string OutputType::ToString() const {
-  if (kind_ == OutputType::FIXED) {
-    return type_->ToString();
-  } else {
-    return "computed";
+  switch (kind_) {
+    case OutputType::FIXED:
+      return type_->ToString();
+    case OutputType::COMPUTED:
+      break;
   }
+  return "computed";

Review Comment:
   ```suggestion
       case OutputType::COMPUTED:
         return "computed";
     }
     return "unknown";
   ```



##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -445,11 +445,13 @@ const TypeMatcher& InputType::type_matcher() const {
 
 Result<TypeHolder> OutputType::Resolve(KernelContext* ctx,
                                        const std::vector<TypeHolder>& types) 
const {
-  if (kind_ == OutputType::FIXED) {
-    return type_.get();
-  } else {
-    return resolver_(ctx, types);
+  switch (kind_) {
+    case OutputType::FIXED:
+      return type_;
+    case OutputType::COMPUTED:
+      break;
   }
+  return resolver_(ctx, types);

Review Comment:
   How about returning an error by default?
   
   ```suggestion
         return resolver_(ctx, types);
     }
     return Status::NotImplemented("Must not happen"); // UnknownError?
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to