File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
src/paimon/core/operation Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments