EnricoMi commented on code in PR #51401:
URL: https://github.com/apache/arrow/pull/51401#discussion_r4069660736


##########
cpp/src/parquet/arrow/reader.cc:
##########
@@ -278,12 +280,18 @@ class FileReaderImpl : public FileReader {
       records_to_read += reader_->metadata()->RowGroup(row_group)->num_rows();
     }
 #ifdef ARROW_WITH_OPENTELEMETRY
-    std::string column_name = reader_->metadata()->schema()->Column(i)->name();
-    std::string phys_type =
-        
TypeToString(reader_->metadata()->schema()->Column(i)->physical_type());
+    const auto& schema_field = manifest_.schema_fields[field_index];
+    const std::string& column_name = schema_field.field->name();

Review Comment:
   Would `field_name` be a better name here?
   ```suggestion
       const std::string& field_name = schema_field.field->name();
   ```



##########
cpp/src/parquet/arrow/reader.cc:
##########
@@ -278,12 +280,18 @@ class FileReaderImpl : public FileReader {
       records_to_read += reader_->metadata()->RowGroup(row_group)->num_rows();
     }
 #ifdef ARROW_WITH_OPENTELEMETRY
-    std::string column_name = reader_->metadata()->schema()->Column(i)->name();
-    std::string phys_type =
-        
TypeToString(reader_->metadata()->schema()->Column(i)->physical_type());
+    const auto& schema_field = manifest_.schema_fields[field_index];
+    const std::string& column_name = schema_field.field->name();
+    std::string phys_type;
+    if (schema_field.is_leaf()) {
+      phys_type = TypeToString(reader_->metadata()
+                                   ->schema()
+                                   ->Column(schema_field.column_index)
+                                   ->physical_type());
+    }
     ::arrow::util::tracing::Span span;
     START_SPAN(span, "parquet::arrow::read_column",
-               {{"parquet.arrow.columnindex", i},
+               {{"parquet.arrow.columnindex", field_index},
                 {"parquet.arrow.columnname", column_name},

Review Comment:
   This would better express the semantics of these values, but it might also 
break things for users.
   ```suggestion
                  {{"parquet.arrow.fieldindex", field_index},
                   {"parquet.arrow.fieldname", field_name},
   ```



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