Class RuleUtils
java.lang.Object
org.elasticsearch.xpack.esql.optimizer.rules.RuleUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.elasticsearch.core.Tuple<List<Alias>, List<NamedExpression>> aliasedNulls(List<Attribute> outputAttributes, Predicate<Attribute> shouldBeReplaced) Returns a tuple of two lists: 1.static AttributeMap<Expression> Collects references to foldable expressions from the given logical plan, returning anAttributeMapthat maps foldable aliases to their corresponding literal values.
-
Method Details
-
aliasedNulls
public static org.elasticsearch.core.Tuple<List<Alias>,List<NamedExpression>> aliasedNulls(List<Attribute> outputAttributes, Predicate<Attribute> shouldBeReplaced) Returns a tuple of two lists: 1. A list of aliases to null literals for those data types in the that . 2. A list of named expressions where attributes that match the predicate are replaced with their corresponding null alias.- Parameters:
outputAttributes- The original output attributes.shouldBeReplaced- A predicate to determine which attributes should be replaced with null aliases.
-
foldableReferencesSkipMVGroupings
public static AttributeMap<Expression> foldableReferencesSkipMVGroupings(LogicalPlan plan, LogicalOptimizerContext ctx) Collects references to foldable expressions from the given logical plan, returning anAttributeMapthat maps foldable aliases to their corresponding literal values.Traverses plan nodes bottom-up. At
Aggregateboundaries, multi-valued grouping keys are removed from the collected references — after GROUP BY, these attributes represent expanded single values, not the original multi-valued literals. This prevents resolving post-Aggregate expressions against stale multi-valued literals, which would produce spurious warnings and incorrect fold results.Note: this MV-grouping removal is applied only at
Aggregateboundaries, not atInlineJoinboundaries (i.e.INLINE STATS). ForINLINE STATS, the join key is always the grouping, and callers are responsible for excludingInlineJoinplans before calling this method — seePruneLeftJoinOnNullMatchingFieldfor an example of that explicit exclusion.- Parameters:
plan- The logical plan to analyze.ctx- The optimizer context providing fold context.- Returns:
- An
AttributeMapcontaining foldable references and their literal values.
-