szehon-ho commented on PR #60147:
URL: https://github.com/apache/spark/pull/60147#issuecomment-6805682084

   The static and runtime `fullyPushedFilterAttributes()` declarations have the 
same signature, but make different promises. Keeping the declarations 
independent lets a connector guarantee exact static filtering without also 
promising exact runtime filtering, or vice versa.
   
   | Contract | `SupportsFullyPushedCatalystFilters` in this PR | 
`SupportsRuntimeCatalystFiltering` |
   | --- | --- | --- |
   | Scope | Declared on the `Table`; fixed for that instance and applies to 
every scan its builders produce, including different read options | Declared on 
an individual `Scan` |
   | Predicate delivery | Static predicates offered to the builder through 
`pushFilters` | Runtime predicates delivered through the scan's `filter` method 
|
   | Enforcement | The source fully evaluates eligible predicates over declared 
fields; it can do so while reading individual rows | The scan fully evaluates 
predicates by pruning input partitions, so a declared attribute's value must be 
fixed within each partition |
   | Valid references | Top-level data and metadata columns, and nested struct 
fields | Fully pushed references must be top-level, present in the scan output, 
and also declared in `filterAttributes()` |
   | Pruned fields | Validate against the full table schema, then ignore valid 
fields absent from the scan output | A declaration absent from the scan output 
fails validation |
   
   `filterAttributes()` alone permits runtime pruning that still needs Spark's 
post-scan evaluation. The runtime `fullyPushedFilterAttributes()` is the 
additional promise that permits Spark to omit that evaluation.
   
   For example, a connector may fully evaluate static `i > 7` while reading 
rows, but only perform coarse runtime partition pruning on `i`, whose values 
vary within a partition. It can declare `i` for static removal and runtime 
filtering, but cannot declare it fully pushed at runtime. Conversely, exact 
runtime pruning supported by one scan does not establish the static guarantee 
for every scan of the table.
   
   The removal rules also differ:
   
   - **Static:** the scan must report inferred filters, every accessed field 
must be covered by the static declaration, and the conjunct must match a 
recorded pushdown candidate: an unchanged returned residual or an adjustment 
predicate. The conjunct must be deterministic and contain no subqueries or 
Python UDFs. Recording candidates ensures a filter introduced after pushdown 
remains executable.
   - **Runtime:** for scalar-subquery predicates that would otherwise remain 
above the scan, Spark removes evaluation only when the predicate is selected 
for runtime pushdown, all referenced attributes are in the runtime fully pushed 
set, and the runtime pushdown eligibility check accepts it. It must be 
deterministic and contain no Python UDFs; runtime subqueries are allowed. There 
is no inferred-filter requirement or static candidate-membership check. 
Group-based operation reads have additional routing restrictions.
   
   We could extract a shared declaration trait, with context-specific 
documentation, while continuing to read the static set from the table and the 
runtime set from the scan. Using one set for both would require connectors to 
satisfy both contracts. Sharing nested-field matching would also require 
changing runtime's root-attribute tracking so declaring `s.part` cannot 
accidentally cover `s.other`.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to