| 930 | } |
| 931 | |
| 932 | Result<std::vector<compute::Expression>> ParquetFileFragment::TestRowGroups( |
| 933 | compute::Expression predicate) { |
| 934 | auto lock = physical_schema_mutex_.Lock(); |
| 935 | |
| 936 | DCHECK_NE(metadata_, nullptr); |
| 937 | ARROW_ASSIGN_OR_RAISE( |
| 938 | predicate, SimplifyWithGuarantee(std::move(predicate), partition_expression_)); |
| 939 | |
| 940 | if (!predicate.IsSatisfiable()) { |
| 941 | return std::vector<compute::Expression>{}; |
| 942 | } |
| 943 | |
| 944 | for (const FieldRef& ref : FieldsInExpression(predicate)) { |
| 945 | ARROW_ASSIGN_OR_RAISE(auto match, ref.FindOneOrNone(*physical_schema_)); |
| 946 | |
| 947 | if (match.empty()) continue; |
| 948 | const SchemaField* schema_field = &manifest_->schema_fields[match[0]]; |
| 949 | |
| 950 | for (size_t i = 1; i < match.indices().size(); ++i) { |
| 951 | if (schema_field->field->type()->id() != Type::STRUCT) { |
| 952 | return Status::Invalid("nested paths only supported for structs"); |
| 953 | } |
| 954 | schema_field = &schema_field->children[match[i]]; |
| 955 | } |
| 956 | |
| 957 | if (!schema_field->is_leaf()) continue; |
| 958 | if (statistics_expressions_complete_[schema_field->column_index]) continue; |
| 959 | statistics_expressions_complete_[schema_field->column_index] = true; |
| 960 | |
| 961 | int i = 0; |
| 962 | for (int row_group : *row_groups_) { |
| 963 | auto row_group_metadata = metadata_->RowGroup(row_group); |
| 964 | |
| 965 | if (auto minmax = ColumnChunkStatisticsAsExpression(ref, *schema_field, |
| 966 | *row_group_metadata)) { |
| 967 | FoldingAnd(&statistics_expressions_[i], std::move(*minmax)); |
| 968 | ARROW_ASSIGN_OR_RAISE(statistics_expressions_[i], |
| 969 | statistics_expressions_[i].Bind(*physical_schema_)); |
| 970 | } |
| 971 | |
| 972 | ++i; |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | std::vector<compute::Expression> row_groups(row_groups_->size()); |
| 977 | for (size_t i = 0; i < row_groups_->size(); ++i) { |
| 978 | ARROW_ASSIGN_OR_RAISE(auto row_group_predicate, |
| 979 | SimplifyWithGuarantee(predicate, statistics_expressions_[i])); |
| 980 | row_groups[i] = std::move(row_group_predicate); |
| 981 | } |
| 982 | return row_groups; |
| 983 | } |
| 984 | |
| 985 | Result<std::optional<int64_t>> ParquetFileFragment::TryCountRows( |
| 986 | compute::Expression predicate) { |
nothing calls this directly
no test coverage detected