Filter pushdown
On this page
Receiving the predicates DuckDB pushed toward the scan.
interface AndFilter
Section titled âinterface AndFilterâexport interface AndFilterFields
typeâandâcolumnNamestringcolumnIndexnumberchildrenFilter[]
function buildJoinKeysLookup
Section titled âfunction buildJoinKeysLookupâexport function buildJoinKeysLookup(joinKeyBatches: VgiBatch[],): (columnName: string) => any[] | nullDescription
Build a getJoinKeysColumn lookup from an InitRequestâs joinKeys batches.
Each batch typically has a single column whose name is the join-keys column
referenced by spec.keys_column on a join_keys filter.
enum ComparisonOp
Section titled âenum ComparisonOpâexport enum ComparisonOp {EQ = "eq",NE = "ne",GT = "gt",GE = "ge",LT = "lt",LE = "le",}interface ConstantFilter
Section titled âinterface ConstantFilterâexport interface ConstantFilterFields
typeâconstantâcolumnNamestringcolumnIndexnumberopComparisonOpvalueany
function deserializeFilters
Section titled âfunction deserializeFiltersâexport function deserializeFilters(batch: VgiBatch,getJoinKeysColumn?: (columnName: string) => any[] | null,): PushdownFiltersDescription
Deserialize pushdown filters from an Arrow RecordBatch.
Wire format:
- Column 0: UTF8 â JSON array of filter specs. Field metadata: vgi_filter_version: â1â
- Columns 1+: Scalar values referenced by value_ref â column N+1
type Filter
Section titled âtype Filterâexport type Filter =| ConstantFilter| IsNullFilter| IsNotNullFilter| InFilter| AndFilter| OrFilter| StructFilter| ExpressionFilter;class FilteringOutputCollector
Section titled âclass FilteringOutputCollectorâexport class FilteringOutputCollectorDescription
Wraps an OutputCollector to automatically apply pushdown filters to every emitted batch.
Properties
Methods
method emit
Section titled âmethod emitâemit(batch: VgiBatch, metadata?: Map<string, string>): void;method clientLog
Section titled âmethod clientLogâclientLog( level: string, message: string, extra?: Record<string, string>,): voidfunction formatPushedFilters
Section titled âfunction formatPushedFiltersâexport function formatPushedFilters(filters: PushdownFilters | undefined): stringDescription
Format pushdown filters as a human-readable SQL-like string. Returns â(none)â when no filters exist.
interface InFilter
Section titled âinterface InFilterâexport interface InFilterFields
typeâinâcolumnNamestringcolumnIndexnumbervaluesSet<any>
interface IsNotNullFilter
Section titled âinterface IsNotNullFilterâexport interface IsNotNullFilterFields
typeâis_not_nullâcolumnNamestringcolumnIndexnumber
interface IsNullFilter
Section titled âinterface IsNullFilterâexport interface IsNullFilterFields
typeâis_nullâcolumnNamestringcolumnIndexnumber
interface OrFilter
Section titled âinterface OrFilterâexport interface OrFilterFields
typeâorâcolumnNamestringcolumnIndexnumberchildrenFilter[]
class PushdownFilters
Section titled âclass PushdownFiltersâexport class PushdownFiltersMethods
method toSql
Section titled âmethod toSqlâtoSql(): stringConvert filters to a human-readable SQL-like string.
method evaluate
Section titled âmethod evaluateâevaluate(batch: VgiBatch): Uint8ArrayEvaluate filters against a batch, returning a Uint8Array mask (0=fail, 1=pass).
method apply
Section titled âmethod applyâapply(batch: VgiBatch): VgiBatchApply filters to a batch, returning only passing rows.
method filteredColumns
Section titled âmethod filteredColumnsâfilteredColumns(): string[]The set of column names referenced by the pushed-down filters, sorted
ascending. Descends one level into AndFilter children (DuckDB pushes
col IN (...) AND col>=min as a single AndFilter), consistent with
getColumnValues / hasFilterForColumn. Mirrors the cross-language
filtered_columns accessor (vgi-python / vgi-go / vgi-rust).
method hasFilterForColumn
Section titled âmethod hasFilterForColumnâhasFilterForColumn(columnName: string): booleanWhether any pushed-down filter references columnName. Mirrors the
cross-language has_filter_for_column accessor.
method getColumnValues
Section titled âmethod getColumnValuesâgetColumnValues(columnName: string): any[] | nullDiscrete values a column could take, from equality (=) or IN filters.
Useful for partition pruning (resolve the key set up front, fetch only
those keys). Returns null when the predicate is not enumerable â no
filter, a bare range, or an OR with a non-discrete branch.
Mirrors vgi-pythonâs PushdownFilters.get_column_values: descends one
level into an AndFilter (DuckDB pushes col IN (...) AND col>=min AND col<=max as a single AndFilter from a semi-join), and unions OR branches
only when every branch pins the column to discrete values.
function reprPushedFilters
Section titled âfunction reprPushedFiltersâexport function reprPushedFilters(filters: PushdownFilters | undefined): stringDescription
Format pushdown filters using Python-style repr() â e.g.
PushdownFilters([ConstantFilter(n < 4999)]). Matches vgi-pythonâs
_format_pushed_filters_safe output so tests that pattern-match the
repr (e.g. dynamic_filter checking for ConstantFilter(n <) work
identically across workers.
interface StructFilter
Section titled âinterface StructFilterâexport interface StructFilterFields
typeâstructâcolumnNamestringcolumnIndexnumberchildIndexnumberchildNamestringchildFilterFilter