public boolean areExpressionsEquivalent(Session session, Expression leftExpression, Expression rightExpression, TypeProvider types) { Map<Symbol, Integer> symbolInput = new HashMap<>(); Map<Integer, Type> inputTypes = new HashMap<>(); int inputId = 0; for (Entry<Symbol, Type> entry : types.allTypes().entrySet()) { symbolInput.put(entry.getKey(), inputId); inputTypes.put(inputId, entry.getValue()); inputId++; } RowExpression leftRowExpression = toRowExpression(session, leftExpression, symbolInput, inputTypes); RowExpression rightRowExpression = toRowExpression(session, rightExpression, symbolInput, inputTypes); RowExpression canonicalizedLeft = leftRowExpression.accept(CANONICALIZATION_VISITOR, null); RowExpression canonicalizedRight = rightRowExpression.accept(CANONICALIZATION_VISITOR, null); return canonicalizedLeft.equals(canonicalizedRight); }
public boolean areExpressionsEquivalent(Session session, Expression leftExpression, Expression rightExpression, Map<Symbol, Type> types) { Map<Symbol, Integer> symbolInput = new HashMap<>(); Map<Integer, Type> inputTypes = new HashMap<>(); int inputId = 0; for (Entry<Symbol, Type> entry : types.entrySet()) { symbolInput.put(entry.getKey(), inputId); inputTypes.put(inputId, entry.getValue()); inputId++; } RowExpression leftRowExpression = toRowExpression(session, leftExpression, symbolInput, inputTypes); RowExpression rightRowExpression = toRowExpression(session, rightExpression, symbolInput, inputTypes); RowExpression canonicalizedLeft = leftRowExpression.accept(CANONICALIZATION_VISITOR, null); RowExpression canonicalizedRight = rightRowExpression.accept(CANONICALIZATION_VISITOR, null); return canonicalizedLeft.equals(canonicalizedRight); }