public static Stream<Expression> getReferencesToScope(Node node, Analysis analysis, Scope scope) {
    Map<NodeRef<Expression>, ResolvedField> columnReferences = analysis.getColumnReferenceFields();

    return preOrder(node)
        .filter(Expression.class::isInstance)
        .map(Expression.class::cast)
        .filter(expression -> columnReferences.containsKey(NodeRef.of(expression)))
        .filter(expression -> isReferenceToScope(expression, scope, columnReferences));
  }
Extract expressions that are references to a given scope.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ScopeReferenceExtractor.java