SteNicholas commented on code in PR #215:
URL: https://github.com/apache/paimon-cpp/pull/215#discussion_r3811960875
##########
src/paimon/core/operation/data_evolution_split_read.cpp:
##########
@@ -424,17 +445,104 @@ Result<std::unique_ptr<BatchReader>>
DataEvolutionSplitRead::InnerCreateReader(
return
std::make_unique<CompleteRowKindBatchReader>(std::move(batch_reader), pool_);
}
+Result<std::shared_ptr<Predicate>>
DataEvolutionSplitRead::CreatePushDownPredicate(
+ const std::shared_ptr<Predicate>& predicate,
+ const std::shared_ptr<arrow::Schema>& read_schema) {
+ std::map<std::string, int32_t> picked_field_name_to_idx;
+ for (int32_t i = 0; i < read_schema->num_fields(); ++i) {
+ const std::string& field_name = read_schema->field(i)->name();
+ if (!SpecialFields::IsSystemField(field_name)) {
+ picked_field_name_to_idx.emplace(field_name, i);
+ }
+ }
+ return PredicateUtils::CreatePickedFieldFilter(predicate,
picked_field_name_to_idx);
+}
+
+Result<bool> DataEvolutionSplitRead::SkipByFileIndex(
+ const std::shared_ptr<Predicate>& predicate,
+ const std::vector<std::shared_ptr<DataFileMeta>>& files,
+ const std::shared_ptr<DataFilePathFactory>& data_file_path_factory) const {
+ if (!options_.FileIndexReadEnabled() || !predicate) {
+ return false;
+ }
+
+ PAIMON_ASSIGN_OR_RAISE(
+ std::unique_ptr<FieldMappingBuilder> field_mapping_builder,
+ FieldMappingBuilder::Create(raw_read_schema_,
context_->GetPartitionKeys(), predicate));
+ std::set<int32_t> claimed_field_ids;
+ for (const auto& file : files) {
+ // Blob and vector-store files may cover only part of the row range,
so their indexes
+ // cannot prove that the complete merged group misses the predicate.
+ if (!DataEvolutionUtils::IsNormalFile(file->file_name)) {
+ continue;
+ }
+
+ std::shared_ptr<TableSchema> data_schema = context_->GetTableSchema();
+ if (file->schema_id != data_schema->Id()) {
+ PAIMON_ASSIGN_OR_RAISE(data_schema,
schema_manager_->ReadSchema(file->schema_id));
+ }
+ std::vector<DataField> written_fields;
+ if (file->write_cols) {
+ PAIMON_ASSIGN_OR_RAISE(written_fields,
Review Comment:
`write_cols` can contain `_ROW_ID` or `_SEQUENCE_NUMBER` (the existing
row-tracking projection helper explicitly skips them), but these system fields
are not part of `TableSchema::Fields()`. Calling `GetFields` directly therefore
returns `Invalid` for a filtered merged-group read whenever file-index reads
are enabled, even if the file has no index. Please reuse
`ProjectFieldsForRowTrackingAndDataEvolution` (removing system fields before
index evaluation if needed), or filter system names here. A merged-group
regression test with explicit row-tracking columns would cover this.
--
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]