@VisibleForTesting
  Expression getScopedCanonical(Expression expression, Predicate<Symbol> symbolScope) {
    Expression canonicalIndex = canonicalMap.get(expression);
    if (canonicalIndex == null) {
      return null;
    }

    Collection<Expression> equivalences = equalitySets.get(canonicalIndex);
    if (expression instanceof SymbolReference) {
      boolean inScope =
          equivalences.stream()
              .filter(SymbolReference.class::isInstance)
              .map(Symbol::from)
              .anyMatch(symbolScope);

      if (!inScope) {
        return null;
      }
    }

    return getCanonical(equivalences.stream().filter(e -> isScoped(e, symbolScope)));
  }
Returns a canonical expression that is fully contained by the symbolScope and that is
equivalent to the specified expression. Returns null if unable to find a canonical.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/EqualityInference.java