zanmato1984 commented on code in PR #45330:
URL: https://github.com/apache/arrow/pull/45330#discussion_r1950285780


##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -835,6 +836,10 @@ Status ParquetFileFragment::SetMetadata(
   DCHECK_EQ(manifest_->descr, original_metadata_->schema())
       << "SchemaDescriptor should be owned by the original FileMetaData";
 
+  if (!physical_schema_) {
+    physical_schema_ = given_physical_schema_;

Review Comment:
   Could elaborate a bit about why this change?



##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -802,12 +802,13 @@ Status 
ParquetFileFragment::EnsureCompleteMetadata(parquet::arrow::FileReader* r
     return EnsureCompleteMetadata(reader.get());
   }
 
+  // TODO temp variable is useless

Review Comment:
   What does this TODO mean?



##########
cpp/src/arrow/dataset/scanner_test.cc:
##########
@@ -922,6 +923,22 @@ std::ostream& operator<<(std::ostream& out, const 
TestScannerParams& params) {
   return out;
 }
 
+// An InMemoryFragment subclass that tracks the calls to ClearCachedMetadata()
+class ClearCachedMetadataFragment : public InMemoryFragment {
+ public:
+  using InMemoryFragment::InMemoryFragment;
+
+  Status ClearCachedMetadata() override {
+    metadata_clear_count_.fetch_add(1);

Review Comment:
   Maybe we should invoke the actual `ClearCachedMetadata()` to do some real 
clearing?



##########
cpp/src/arrow/dataset/scanner.cc:
##########
@@ -318,10 +319,14 @@ Result<EnumeratedRecordBatchGenerator> FragmentToBatches(
       RecordBatch::Make(options->dataset_schema, /*num_rows=*/0, 
std::move(columns)));
   auto enumerated_batch_gen = MakeEnumeratedGenerator(std::move(batch_gen));
 
-  auto combine_fn =
-      [fragment](const Enumerated<std::shared_ptr<RecordBatch>>& record_batch) 
{
-        return EnumeratedRecordBatch{record_batch, fragment};
-      };
+  auto combine_fn = [fragment, cache_metadata = options->cache_metadata](
+                        const Enumerated<std::shared_ptr<RecordBatch>>& 
record_batch) {
+    if (!cache_metadata && record_batch.last) {
+      ARROW_WARN_NOT_OK(fragment.value->ClearCachedMetadata(),
+                        "Could not clear cached metadata on fragment");
+    }

Review Comment:
   This is OK but I wonder can we extend `MappedGenerator` by accepting an 
optional continuation to be invoked once the generator is exhausted? Then we 
can clear the cached metadata in that continuation - not having to check the 
last-ness of the record batch.



##########
cpp/src/arrow/dataset/scanner_test.cc:
##########
@@ -922,6 +923,22 @@ std::ostream& operator<<(std::ostream& out, const 
TestScannerParams& params) {
   return out;
 }
 
+// An InMemoryFragment subclass that tracks the calls to ClearCachedMetadata()
+class ClearCachedMetadataFragment : public InMemoryFragment {
+ public:
+  using InMemoryFragment::InMemoryFragment;
+
+  Status ClearCachedMetadata() override {
+    metadata_clear_count_.fetch_add(1);

Review Comment:
   ```suggestion
       RETURN_NOT_OK(InMemoryFragment::ClearCachedMetadata());
       metadata_clear_count_.fetch_add(1);
   ```



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