plusplusjiajia commented on code in PR #8447:
URL: https://github.com/apache/paimon/pull/8447#discussion_r3520179351
##########
paimon-core/src/main/java/org/apache/paimon/table/source/AbstractDataTableScan.java:
##########
@@ -111,6 +117,37 @@ public final TableScan.Plan plan() {
protected abstract TableScan.Plan planWithoutAuth();
+ private void applyAuthFilter(@Nullable Predicate authPredicate) {
+ if (Objects.equals(authPredicate, appliedAuthPredicate)) {
+ return;
+ }
+ appliedAuthPredicate = authPredicate;
+
+ PartitionPredicate authPartitionFilter = null;
+ boolean hasNonPartitionPart = false;
+ if (authPredicate != null) {
+ // Remap field-id FieldRefs to positional indices by name (as
doAuth does on read), so
+ // pruning stays correct across schema evolution.
+ Predicate remappedAuth =
+ TableQueryAuthResult.remapPredicate(authPredicate,
schema.logicalRowType());
+ if (remappedAuth != null) {
+ Pair<Optional<PartitionPredicate>, List<Predicate>> split =
+
PartitionPredicate.splitPartitionPredicatesAndDataPredicates(
+ remappedAuth, schema.logicalRowType(),
schema.partitionKeys());
+ authPartitionFilter = split.getLeft().orElse(null);
+ hasNonPartitionPart = !split.getRight().isEmpty();
+ }
+ }
+
+ // Push only the partition part, to a dedicated slot
overwritten/cleared each plan() so a
+ // changed/removed auth leaves no stale pruning. The full filter is
enforced at read time.
+
snapshotReader.manifestsReader().withAuthPartitionFilter(authPartitionFilter);
+ if (hasNonPartitionPart) {
+ // Non-partition auth removes rows at read time, so limit push
down is unsafe.
+ snapshotReader.markHasNonPartitionFilter();
Review Comment:
@JingsongLi good point! dropped it from SnapshotReader, kept the flag
scan-local in DataTableBatchScan.
--
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]