dtenedor commented on code in PR #50892:
URL: https://github.com/apache/arrow/pull/50892#discussion_r3916842613


##########
cpp/src/parquet/arrow/schema.cc:
##########
@@ -602,13 +628,21 @@ Status GroupToStruct(const GroupNode& node, LevelInfo 
current_levels,
     arrow_fields.push_back(out->children[i].field);
   }
   auto struct_type = ::arrow::struct_(arrow_fields);
-  if (ctx->properties.get_arrow_extensions_enabled() &&
-      node.logical_type()->is_variant()) {
-    auto extension_type = ::arrow::GetExtensionType("arrow.parquet.variant");
-    if (extension_type) {
-      ARROW_ASSIGN_OR_RAISE(
-          struct_type,
-          extension_type->Deserialize(std::move(struct_type), 
/*serialized_data=*/""));
+  if (ctx->properties.get_arrow_extensions_enabled()) {
+    if (node.logical_type()->is_variant()) {
+      auto extension_type = ::arrow::GetExtensionType("arrow.parquet.variant");
+      if (extension_type) {
+        ARROW_ASSIGN_OR_RAISE(
+            struct_type,
+            extension_type->Deserialize(std::move(struct_type), 
/*serialized_data=*/""));
+      }
+    } else if (node.logical_type()->is_file()) {
+      auto extension_type = 
::arrow::GetExtensionType(std::string(kFileExtensionName));
+      if (extension_type) {
+        ARROW_ASSIGN_OR_RAISE(
+            struct_type,
+            extension_type->Deserialize(std::move(struct_type), 
/*serialized_data=*/""));

Review Comment:
   Here, any FILE-annotated group whose fields don't match the recognized set 
makes the entire read fail (`Status::Invalid`) rather than falling back to a 
plain struct.
   
   Should we consider attempting `Deserialize` and keeping the plain 
`struct_type` on error? This would mirror `variant`'s current behavior.
   
   



##########
cpp/src/parquet/arrow/schema.cc:
##########
@@ -1059,9 +1094,16 @@ Result<bool> ApplyOriginalStorageMetadata(const Field& 
origin_field,
 
       // Apply original metadata recursively to children
       for (int i = 0; i < inferred_type->num_fields(); ++i) {
+        std::shared_ptr<::arrow::Field> origin_child;
+        if (match_children_by_name) {
+          origin_child = checked_cast<const ::arrow::StructType&>(*origin_type)

Review Comment:
   `GetFieldByName` returns nullptr if the name is missing or ambiguous. Should 
we `DCHECK(origin_child != nullptr)` (or `return Status::Invalid`)? 



##########
cpp/src/parquet/parquet.thrift:
##########
@@ -637,6 +649,14 @@ enum Encoding {
       Support for INT32, INT64 and FIXED_LEN_BYTE_ARRAY added in 2.11.
    */
   BYTE_STREAM_SPLIT = 9;
+
+  /** Adaptive Lossless floating-Point (ALP) encoding for FLOAT and DOUBLE.
+      Losslessly converts decimal-like floating-point values to integers via
+      decimal scaling, then applies Frame of Reference (FOR) encoding and
+      bit-packing; values that cannot be converted losslessly are stored as

Review Comment:
   Is it intended to bring this in as well in this PR?



##########
cpp/src/parquet/arrow/arrow_schema_test.cc:
##########
@@ -1061,6 +1063,52 @@ TEST_F(TestConvertParquetSchema, ParquetVariant) {
   }
 }
 
+TEST_F(TestConvertParquetSchema, ParquetFile) {
+  std::vector<NodePtr> parquet_fields;
+  parquet_fields.push_back(PrimitiveNode::Make(
+      "uri", Repetition::OPTIONAL, LogicalType::String(), 
ParquetType::BYTE_ARRAY));
+  parquet_fields.push_back(PrimitiveNode::Make("offset", Repetition::OPTIONAL,
+                                               LogicalType::None(), 
ParquetType::INT64));
+  parquet_fields.push_back(PrimitiveNode::Make(
+      "inline", Repetition::OPTIONAL, LogicalType::None(), 
ParquetType::BYTE_ARRAY));
+  auto file =
+      GroupNode::Make("file", Repetition::OPTIONAL, parquet_fields, 
LogicalType::File());
+
+  auto storage = ::arrow::struct_({::arrow::field("uri", ::arrow::utf8()),
+                                   ::arrow::field("offset", ::arrow::int64()),
+                                   ::arrow::field("inline", 
::arrow::binary())});

Review Comment:
   The accepted storage types are broader than what's tested: 
`IsSupportedField` allows `large_utf8`/`utf8_view` and 
`large_binary`/`binary_view`, but round-trip tests only use 
`utf8`/`int64`/`binary`. Should we add at least one view/large variant 
round-trip?
   



##########
cpp/src/arrow/extension/parquet_file_test.cc:
##########
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <vector>
+
+#include <gtest/gtest.h>
+
+#include "arrow/extension/parquet_file.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow::extension {
+
+TEST(FileType, InvalidStorage) {

Review Comment:
   Other test ideas:
   
   * an unknown extra field alongside the valid ones
   * a `REQUIRED` field among otherwise-valid ones
   * wrong types for `content_type`/`checksum`/`size` (only 
`uri`/`offset`/`inline` type-errors are tested)
   



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