rok commented on code in PR #55498:
URL: https://github.com/apache/arrow/pull/55498#discussion_r4564436667


##########
cpp/src/arrow/json/from_string.cc:
##########
@@ -167,10 +167,16 @@ class BooleanConverter final : public 
ConcreteConverter<BooleanConverter> {
     if (is_null) {
       return AppendNull();
     }
-    int64_t int_value;
-    if (json_obj.get(int_value) == simdjson::SUCCESS) {
+    ARROW_ASSIGN_OR_RAISE(
+        auto json_type, internal::ResolveSimdjsonResult(json_obj.type(),
+                                                        "Failed to determine 
JSON type"));
+    if (json_type == sj::json_type::number) {
+      ARROW_ASSIGN_OR_RAISE(auto int_value, 
internal::GetJsonAs<int64_t>(json_obj));
       return builder_->Append(int_value != 0);
     }
+    if (json_type != sj::json_type::boolean) {
+      return Status::Invalid("Expected JSON boolean for type ", 
type_->ToString());
+    }

Review Comment:
   This logic seems to repeat at least partially two more times below. Could we 
abstract it into the helper as well? Not at any cost of course.



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