Class FilterAdaptation
In UNION_BY_NAME scenarios, different files may have different columns. When a pushed filter
references a column absent from a file, the predicate must be simplified before re-translation
to the format-specific filter (Parquet FilterPredicate, ORC SearchArgument).
Adaptation rules for missing columns (SQL three-valued logic):
- Value comparison on missing column → UNKNOWN → FALSE in WHERE → remove conjunct
IS NULLon missing column → TRUE (all rows match) → remove conjunct (always true)IS NOT NULLon missing column → FALSE → remove conjunct (entire AND is false)AND(A, B): if either is null (FALSE) → null; if either is TRUE → other sideOR(A, B): if either is TRUE → TRUE; if one is null → other sideNOT(child): if child is null → TRUE; if child is TRUE → null
RECHECK semantics guarantee correctness: the adapted filter only affects I/O optimization (row-group/stripe skipping), never row-level correctness.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<Expression> adaptFilterForFile(List<Expression> filterConjuncts, Set<String> fileColumnNames) Adapts pushed filter conjuncts for a specific file's column set.static List<Expression> adaptFilterForFile(List<Expression> filterConjuncts, Set<String> fileColumnNames, Map<String, DataType> fileColumnTypes) Adapts pushed filter conjuncts for a specific file's column set and types.
-
Method Details
-
adaptFilterForFile
public static List<Expression> adaptFilterForFile(List<Expression> filterConjuncts, Set<String> fileColumnNames) Adapts pushed filter conjuncts for a specific file's column set. Removes or simplifies predicates on columns absent from the file.- Parameters:
filterConjuncts- AND-separated pushed expressions (same contract asFilterPushdownSupport.pushFilters(java.util.List<org.elasticsearch.xpack.esql.core.expression.Expression>)input)fileColumnNames- names of columns present in this file's schema- Returns:
- adapted conjuncts; empty list means no pushdown for this file
-
adaptFilterForFile
public static List<Expression> adaptFilterForFile(List<Expression> filterConjuncts, Set<String> fileColumnNames, Map<String, DataType> fileColumnTypes) Adapts pushed filter conjuncts for a specific file's column set and types. Handles both missing columns and type-widened columns.When a column exists in the file with a narrower type than the unified schema (e.g., INTEGER in file vs LONG in unified), filter literals are downcast to the file's native type for optimal row-group/stripe skipping. Literals that overflow the narrower range are statically resolved based on the comparison operator.
- Parameters:
filterConjuncts- AND-separated pushed expressionsfileColumnNames- names of columns present in this file's schemafileColumnTypes- file-local types for columns that differ from the unified schema; columns not in this map are assumed to match the unified type- Returns:
- adapted conjuncts; empty list means no pushdown for this file
-