diff --git a/cpp/src/arrow/dataset/file_parquet.cc b/cpp/src/arrow/dataset/file_parquet.cc index 0f939d7da71..d1969ed87af 100644 --- a/cpp/src/arrow/dataset/file_parquet.cc +++ b/cpp/src/arrow/dataset/file_parquet.cc @@ -385,12 +385,25 @@ Result ParquetFileFormat::ScanFile(std::shared_ptrsource(), options.get(), context.get())); if (!parquet_fragment->HasCompleteMetadata()) { - // row groups were not already filtered; do this now - RETURN_NOT_OK(parquet_fragment->EnsureCompleteMetadata(reader.get())); - ARROW_ASSIGN_OR_RAISE(row_groups, - parquet_fragment->FilterRowGroups(*options->filter)); - if (row_groups.empty()) { - return MakeEmptyIterator>(); + // row groups were not already filtered; do this now (if there is a filter) + if (!options->filter->Equals(true)) { + RETURN_NOT_OK(parquet_fragment->EnsureCompleteMetadata(reader.get())); + ARROW_ASSIGN_OR_RAISE(row_groups, + parquet_fragment->FilterRowGroups(*options->filter)); + if (row_groups.empty()) { + return MakeEmptyIterator>(); + } + } else { + // since we are not scanning this fragment with a filter, don't bother loading + // statistics + row_groups = parquet_fragment->row_groups(); + if (row_groups.empty()) { + // empty vector represents all row groups + std::shared_ptr metadata = + reader->parquet_reader()->metadata(); + int num_row_groups = metadata->num_row_groups(); + row_groups = RowGroupInfo::FromCount(num_row_groups); + } } }