private static Set<Symbol> extractInliningTargets(
      PlannerContext plannerContext,
      ProjectNode parent,
      ProjectNode child,
      SessionInfo sessionInfo,
      TypeProvider types) {
    // candidates for inlining are
    //   1. references to simple constants or symbol references
    //   2. references to complex expressions that
    //      a. are not inputs to try() expressions
    //      b. appear only once across all expressions
    //      c. are not identity projections
    // which come from the child, as opposed to an enclosing scope.

    Set<Symbol> childOutputSet = ImmutableSet.copyOf(child.getOutputSymbols());

    Map<Symbol, Long> dependencies =
        parent.getAssignments().getExpressions().stream()
            .flatMap(expression -> SymbolsExtractor.extractAll(expression).stream())
            .filter(childOutputSet::contains)
            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

    // find references to simple constants or symbol references
    Set<Symbol> basicReferences =
        dependencies.keySet().stream()
            .filter(
                input ->
                    isEffectivelyLiteral(
                            child.getAssignments().get(input), plannerContext, sessionInfo)
                        || child.getAssignments().get(input) instanceof SymbolReference)
            .filter(
                input ->
                    !child
                        .getAssignments()
                        .isIdentity(
                            input)) // skip identities, otherwise, this rule will keep firing
            // forever
            .collect(toSet());

    Set<Symbol> singletons =
        dependencies.entrySet().stream()
            .filter(
                entry ->
                    entry.getValue()
                        == 1) // reference appears just once across all expressions in parent
            // project node
            .filter(
                entry ->
                    !child
                        .getAssignments()
                        .isIdentity(
                            entry.getKey())) // skip identities, otherwise, this rule will keep
            .map(Map.Entry::getKey)
            .collect(toSet());

    return Sets.union(singletons, basicReferences);
  }
Inlines expressions from a child project node into a parent project node as long as they are
simple constants, or they are referenced only once (to avoid introducing duplicate computation)
and the references don't appear within a TRY block (to avoid changing semantics).
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/iterative/rule/InlineProjections.java