Skip to content

Commit a4bcf37

Browse files
authored
Merge branch 'main' into add-compact-strategy
2 parents b7914e4 + 32aa8ca commit a4bcf37

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/paimon/core/operation/key_value_file_store_scan.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,29 @@ Status KeyValueFileStoreScan::SplitAndSetKeyValueFilter(
113113
}
114114
WithKeyFilter(key_filter);
115115
}
116-
// support value filter in bucket level
117-
WithValueFilter(predicates_);
116+
117+
// Only set value filtering when there are predicates on non-primary-key fields.
118+
//
119+
// For primary key tables, we cannot safely push down arbitrary value predicates to each
120+
// individual file (see the comment above). When value filtering is enabled, we will filter
121+
// by stats either per file (when no overlapping) or by whole bucket (when overlapping).
122+
//
123+
// For key-only predicates, key_stats based filtering is enough and enabling value filtering
124+
// may trigger unsupported paths (e.g. DataFileMeta::value_stats_cols).
125+
std::set<std::string> field_names;
126+
PAIMON_RETURN_NOT_OK(PredicateUtils::GetAllNames(predicates_, &field_names));
127+
std::set<std::string> pk_names(trimmed_pk.begin(), trimmed_pk.end());
128+
bool has_non_pk_predicate = false;
129+
for (const auto& name : field_names) {
130+
if (pk_names.find(name) == pk_names.end()) {
131+
has_non_pk_predicate = true;
132+
break;
133+
}
134+
}
135+
if (has_non_pk_predicate) {
136+
// support value filter in bucket level
137+
WithValueFilter(predicates_);
138+
}
118139
return Status::OK();
119140
}
120141

0 commit comments

Comments
 (0)