JackDrogon commented on code in PR #39937:
URL: https://github.com/apache/arrow/pull/39937#discussion_r1479617514


##########
cpp/src/arrow/datum.h:
##########
@@ -170,22 +170,27 @@ struct ARROW_EXPORT Datum {
 
   /// \brief The kind of data stored in Datum
   Datum::Kind kind() const {
-    switch (this->value.index()) {
-      case 0:
-        return Datum::NONE;
-      case 1:
-        return Datum::SCALAR;
-      case 2:
-        return Datum::ARRAY;
-      case 3:
-        return Datum::CHUNKED_ARRAY;
-      case 4:
-        return Datum::RECORD_BATCH;
-      case 5:
-        return Datum::TABLE;
-      default:
-        return Datum::NONE;
-    }
+    return std::visit(
+        [](const auto& value) -> Datum::Kind {
+          using T = std::decay_t<decltype(value)>;
+
+          if constexpr (std::is_same_v<T, Empty>) {
+            return Datum::NONE;
+          } else if constexpr (std::is_same_v<T, std::shared_ptr<Scalar>>) {
+            return Datum::SCALAR;
+          } else if constexpr (std::is_same_v<T, std::shared_ptr<ArrayData>>) {
+            return Datum::ARRAY;
+          } else if constexpr (std::is_same_v<T, 
std::shared_ptr<ChunkedArray>>) {
+            return Datum::CHUNKED_ARRAY;
+          } else if constexpr (std::is_same_v<T, 
std::shared_ptr<RecordBatch>>) {
+            return Datum::RECORD_BATCH;
+          } else if constexpr (std::is_same_v<T, std::shared_ptr<Table>>) {
+            return Datum::TABLE;
+          } else {
+            static_assert(!std::is_same_v<T, T>, "unhandled type");

Review Comment:
   we need `!std::is_same_v<T, T>` or `always_false<T>` for compile show the 
error with type, it's better for  debug



-- 
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