Class AstUtils
java.lang.Object
io.trino.sql.util.AstUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<Expression> extractConjuncts(Expression expression) static booleanCompares two AST trees recursively by applying the provided comparator to each pair of nodes.static inttreeHash(Node node, Function<Node, OptionalInt> subtreeHasher) Computes a hash of the given AST by applying the provided subtree hasher at each level.
-
Method Details
-
preOrder
-
treeEqual
public static boolean treeEqual(Node left, Node right, BiFunction<Node, Node, Boolean> subtreeComparator) Compares two AST trees recursively by applying the provided comparator to each pair of nodes.
The comparator can perform a hybrid shallow/deep comparison. If it returns true or false, the nodes and any subtrees are considered equal or different, respectively. If it returns null, the nodes are considered shallowly-equal and their children will be compared recursively.
-
treeHash
Computes a hash of the given AST by applying the provided subtree hasher at each level.
If the hasher returns a non-empty
OptionalInt, the value is treated as the hash for the subtree at that node. Otherwise, the hashes of its children are computed and combined. -
extractConjuncts
-