You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "rok (via GitHub)" <gi...@apache.org> on 2024/09/24 11:58:16 UTC

[PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

rok opened a new pull request, #44215:
URL: https://github.com/apache/arrow/pull/44215

   ### Rationale for this change
   
   As noted in https://github.com/apache/arrow/pull/13901#pullrequestreview-2324294761:
   ```cpp
   bool JsonExtensionType::ExtensionEquals(const ExtensionType& other) const {
     return other.extension_name() == this->extension_name();
   }
   ```
   > This equality check does not take into account the storage type, but only the name.
   > As a consequence, a JsonExtensionType<string> type will be seen as equal to JsonExtensionType<large_string>.
   
   ### What changes are included in this PR?
   
   This change introduces storage equality check into `JsonExtensionType` equality check.
   
   This also fixes a storage type check in `JsonExtensionType::Make`.
   
   ### Are these changes tested?
   
   Yes.
   
   ### Are there any user-facing changes?
   
   No.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774051008


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   (There was a test where arrow schema was available and wasn't used at read time. I've addressed that)



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1775319895


##########
cpp/src/parquet/arrow/schema.cc:
##########
@@ -1017,7 +1017,9 @@ Result<bool> ApplyOriginalMetadata(const Field& origin_field, SchemaField* infer
 
       // Restore extension type, if the storage type is the same as inferred
       // from the Parquet type
-      if (ex_type.storage_type()->Equals(*inferred->field->type())) {
+      if (ex_type.storage_type()->Equals(*inferred->field->type()) ||
+          (ex_type.extension_name() == "arrow.json" &&
+           !ex_type.storage_type()->Equals(*inferred->field->type()))) {

Review Comment:
   This "types are not equal" check is superfluous? Because if they were equal, the first part of the if check would have passed and we wouldn't get here?
   
   I assume that in case of JSON extension type, we either just have to assume that the data will correctly use string, or we check explicitly that the inferred type is string type?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774871649


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   Yes.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #44215:
URL: https://github.com/apache/arrow/pull/44215#issuecomment-2374642978

   > Remaining nits
   
   @pitrou added your changes.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1775449866


##########
cpp/src/parquet/arrow/schema.cc:
##########
@@ -1017,7 +1017,9 @@ Result<bool> ApplyOriginalMetadata(const Field& origin_field, SchemaField* infer
 
       // Restore extension type, if the storage type is the same as inferred
       // from the Parquet type
-      if (ex_type.storage_type()->Equals(*inferred->field->type())) {
+      if (ex_type.storage_type()->Equals(*inferred->field->type()) ||
+          (ex_type.extension_name() == "arrow.json" &&
+           !ex_type.storage_type()->Equals(*inferred->field->type()))) {

Review Comment:
   It is superfluous indeed. Changed as per your suggestion: https://github.com/apache/arrow/pull/44215/commits/3364c0f0f70a37c84e134043537c4ee4d55fbbd6



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1775619683


##########
cpp/src/arrow/extension/json.cc:
##########
@@ -28,17 +28,13 @@
 namespace arrow::extension {
 
 bool JsonExtensionType::ExtensionEquals(const ExtensionType& other) const {
-  return other.extension_name() == this->extension_name();
+  return other.extension_name() == this->extension_name() &&
+         other.storage_type()->Equals(storage_type_);
 }
 
 Result<std::shared_ptr<DataType>> JsonExtensionType::Deserialize(
     std::shared_ptr<DataType> storage_type, const std::string& serialized) const {
-  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&
-      storage_type->id() != Type::LARGE_STRING) {
-    return Status::Invalid("Invalid storage type for JsonExtensionType: ",
-                           storage_type->ToString());
-  }
-  return std::make_shared<JsonExtensionType>(storage_type);
+  return JsonExtensionType::Make(storage_type);

Review Comment:
   ```suggestion
     return JsonExtensionType::Make(std::move(storage_type));
   ```



##########
cpp/src/arrow/extension/json.cc:
##########
@@ -51,11 +47,18 @@ std::shared_ptr<Array> JsonExtensionType::MakeArray(
   return std::make_shared<ExtensionArray>(data);
 }
 
-std::shared_ptr<DataType> json(const std::shared_ptr<DataType> storage_type) {
-  ARROW_CHECK(storage_type->id() != Type::STRING ||
-              storage_type->id() != Type::STRING_VIEW ||
-              storage_type->id() != Type::LARGE_STRING);
+Result<std::shared_ptr<DataType>> JsonExtensionType::Make(
+    std::shared_ptr<DataType> storage_type) {
+  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&
+      storage_type->id() != Type::LARGE_STRING) {
+    return Status::Invalid("Invalid storage type for JsonExtensionType: ",
+                           storage_type->ToString());
+  }
   return std::make_shared<JsonExtensionType>(storage_type);

Review Comment:
   ```suggestion
     return std::make_shared<JsonExtensionType>(std::move(storage_type));
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1773245873


##########
cpp/src/arrow/extension/json.h:
##########
@@ -45,12 +45,14 @@ class ARROW_EXPORT JsonExtensionType : public ExtensionType {
 
   std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
 
+  static Result<std::shared_ptr<DataType>> Make(const std::shared_ptr<DataType>& storage_type);
+
  private:
   std::shared_ptr<DataType> storage_type_;
 };
 
 /// \brief Return a JsonExtensionType instance.
 ARROW_EXPORT std::shared_ptr<DataType> json(
-    std::shared_ptr<DataType> storage_type = utf8());
+    const std::shared_ptr<DataType>& storage_type = utf8());

Review Comment:
   The original signature was slightly better, since it didn't imply a `std::shared_ptr` copy. Though it arguably doesn't matter much.



##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   Instead of making the test easier, can you keep `large_utf8` and ensure it passes?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774024385


##########
cpp/src/arrow/extension/json.h:
##########
@@ -45,12 +45,14 @@ class ARROW_EXPORT JsonExtensionType : public ExtensionType {
 
   std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
 
+  static Result<std::shared_ptr<DataType>> Make(const std::shared_ptr<DataType>& storage_type);
+
  private:
   std::shared_ptr<DataType> storage_type_;
 };
 
 /// \brief Return a JsonExtensionType instance.
 ARROW_EXPORT std::shared_ptr<DataType> json(
-    std::shared_ptr<DataType> storage_type = utf8());
+    const std::shared_ptr<DataType>& storage_type = utf8());

Review Comment:
   Sorry for that. Restoring.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1776881585


##########
cpp/src/arrow/extension/json.cc:
##########
@@ -51,11 +47,18 @@ std::shared_ptr<Array> JsonExtensionType::MakeArray(
   return std::make_shared<ExtensionArray>(data);
 }
 
-std::shared_ptr<DataType> json(const std::shared_ptr<DataType> storage_type) {
-  ARROW_CHECK(storage_type->id() != Type::STRING ||
-              storage_type->id() != Type::STRING_VIEW ||
-              storage_type->id() != Type::LARGE_STRING);
-  return std::make_shared<JsonExtensionType>(storage_type);
+Result<std::shared_ptr<DataType>> JsonExtensionType::Make(
+    std::shared_ptr<DataType> storage_type) {
+  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&

Review Comment:
   Changed as suggested: https://github.com/apache/arrow/pull/44215/commits/1dd3ec2fe99e986dcb67335f0543b18f1904bc86



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774868325


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   Something like this? https://github.com/apache/arrow/pull/44215/commits/e522efb7a0d291573e8c44548b68e9d120e70328



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1776206695


##########
cpp/src/arrow/extension/json.cc:
##########
@@ -51,11 +47,18 @@ std::shared_ptr<Array> JsonExtensionType::MakeArray(
   return std::make_shared<ExtensionArray>(data);
 }
 
-std::shared_ptr<DataType> json(const std::shared_ptr<DataType> storage_type) {
-  ARROW_CHECK(storage_type->id() != Type::STRING ||
-              storage_type->id() != Type::STRING_VIEW ||
-              storage_type->id() != Type::LARGE_STRING);
-  return std::make_shared<JsonExtensionType>(storage_type);
+Result<std::shared_ptr<DataType>> JsonExtensionType::Make(
+    std::shared_ptr<DataType> storage_type) {
+  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&

Review Comment:
   Should we add the following static function to `JsonExtensionType` to remove repeated code here and in cpp/src/parquet/arrow/schema.cc below?
   
   ```
   static bool IsSupportedStorageType(Type::type type_id) {
     return type_id == Type::STRING || type_id == Type::STRING_VIEW || type_id == Type::LARGE_STRING;
   }
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #44215:
URL: https://github.com/apache/arrow/pull/44215#issuecomment-2401048820

   After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 64891d1d176dd45f3fae574e1bcfac6fee197e5f.
   
   There were no benchmark performance regressions. 🎉
   
   The [full Conbench report](https://github.com/apache/arrow/runs/31267167824) has more details. It also includes information about 4 possible false positives for unstable benchmarks that are known to sometimes produce them.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774043187


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   Can we reconstruct storage type if it is not stored? In this case we know data is of JSON logical type, but we don't know what was it's storage type at write time. Am I missing something?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #44215:
URL: https://github.com/apache/arrow/pull/44215#issuecomment-2371060233

   :warning: GitHub issue #44214 **has been automatically assigned in GitHub** to PR creator.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1775489229


##########
cpp/src/arrow/extension/json.cc:
##########
@@ -51,11 +47,18 @@ std::shared_ptr<Array> JsonExtensionType::MakeArray(
   return std::make_shared<ExtensionArray>(data);
 }
 
-std::shared_ptr<DataType> json(const std::shared_ptr<DataType> storage_type) {
-  ARROW_CHECK(storage_type->id() != Type::STRING ||
-              storage_type->id() != Type::STRING_VIEW ||
-              storage_type->id() != Type::LARGE_STRING);
+Result<std::shared_ptr<DataType>> JsonExtensionType::Make(
+    const std::shared_ptr<DataType>& storage_type) {
+  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&
+      storage_type->id() != Type::LARGE_STRING) {
+    return Status::Invalid("Invalid storage type for JsonExtensionType: ",
+                           storage_type->ToString());
+  }
   return std::make_shared<JsonExtensionType>(storage_type);
 }
 
+std::shared_ptr<DataType> json(std::shared_ptr<DataType> storage_type) {
+  return JsonExtensionType::Make(storage_type).ValueOrDie();

Review Comment:
   ```suggestion
     return JsonExtensionType::Make(std::move(storage_type)).ValueOrDie();
   ```
   
   Also, please ensure that `JsonExtensionType::Make` takes a `std::shared_ptr<DataType>`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774837133


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   > Can we reconstruct storage type if it is not stored? In this case we know data is of JSON logical type, but we don't know what was it's storage type at write time. Am I missing something?
   
   No, I'm asking you to write the test so that it reflects that.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1774937588


##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -763,7 +763,7 @@ TEST_F(TestConvertParquetSchema, ParquetSchemaArrowExtensions) {
     props.set_arrow_extensions_enabled(true);
     auto arrow_schema = ::arrow::schema(
         {::arrow::field("json_1", ::arrow::extension::json(), true),
-         ::arrow::field("json_2", ::arrow::extension::json(::arrow::large_utf8()),
+         ::arrow::field("json_2", ::arrow::extension::json(::arrow::utf8()),

Review Comment:
   Added another assertion to justify changing `arrow_schema` https://github.com/apache/arrow/pull/44215/files/94006f92085377fc4b72c2a2da844e36fb4d86d3..77c964b04972fc08f04957190866fb475b453c3c.
   Let me know if something else should be changed.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1775501455


##########
cpp/src/arrow/extension/json.cc:
##########
@@ -51,11 +47,18 @@ std::shared_ptr<Array> JsonExtensionType::MakeArray(
   return std::make_shared<ExtensionArray>(data);
 }
 
-std::shared_ptr<DataType> json(const std::shared_ptr<DataType> storage_type) {
-  ARROW_CHECK(storage_type->id() != Type::STRING ||
-              storage_type->id() != Type::STRING_VIEW ||
-              storage_type->id() != Type::LARGE_STRING);
+Result<std::shared_ptr<DataType>> JsonExtensionType::Make(
+    const std::shared_ptr<DataType>& storage_type) {
+  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&
+      storage_type->id() != Type::LARGE_STRING) {
+    return Status::Invalid("Invalid storage type for JsonExtensionType: ",
+                           storage_type->ToString());
+  }
   return std::make_shared<JsonExtensionType>(storage_type);
 }
 
+std::shared_ptr<DataType> json(std::shared_ptr<DataType> storage_type) {
+  return JsonExtensionType::Make(storage_type).ValueOrDie();

Review Comment:
   Done.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44214: [C++] JsonExtensionType equality check ignores storage type [arrow]

Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #44215:
URL: https://github.com/apache/arrow/pull/44215#discussion_r1776881585


##########
cpp/src/arrow/extension/json.cc:
##########
@@ -51,11 +47,18 @@ std::shared_ptr<Array> JsonExtensionType::MakeArray(
   return std::make_shared<ExtensionArray>(data);
 }
 
-std::shared_ptr<DataType> json(const std::shared_ptr<DataType> storage_type) {
-  ARROW_CHECK(storage_type->id() != Type::STRING ||
-              storage_type->id() != Type::STRING_VIEW ||
-              storage_type->id() != Type::LARGE_STRING);
-  return std::make_shared<JsonExtensionType>(storage_type);
+Result<std::shared_ptr<DataType>> JsonExtensionType::Make(
+    std::shared_ptr<DataType> storage_type) {
+  if (storage_type->id() != Type::STRING && storage_type->id() != Type::STRING_VIEW &&

Review Comment:
   Changed as suggested: https://github.com/apache/arrow/pull/44215/commits/6dff127adf94bf94972672036dde15f7e905f29e



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org