Remove identity-collection use in DomainTranslator
@@ -30,7 +30,6 @@ import com.facebook.presto.spi.predicate.ValueSet;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.sql.FunctionInvoker;
import com.facebook.presto.sql.analyzer.ExpressionAnalyzer;
-import com.facebook.presto.sql.analyzer.NodeRefCollections;
import com.facebook.presto.sql.parser.SqlParser;
import com.facebook.presto.sql.tree.AstVisitor;
import com.facebook.presto.sql.tree.BetweenPredicate;
@@ -48,7 +47,6 @@ import com.facebook.presto.sql.tree.NodeRef;
import com.facebook.presto.sql.tree.NotExpression;
import com.facebook.presto.sql.tree.NullLiteral;
import com.facebook.presto.sql.tree.SymbolReference;
-import com.facebook.presto.util.maps.IdentityLinkedHashMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.PeekingIterator;
@@ -455,7 +453,7 @@ public final class DomainTranslator
*/
private Optional<NormalizedSimpleComparison> toNormalizedSimpleComparison(ComparisonExpression comparison)
{
- Map<NodeRef<Expression>, Type> expressionTypes = NodeRefCollections.fromIdentityMap(analyzeExpression(comparison));
+ Map<NodeRef<Expression>, Type> expressionTypes = analyzeExpression(comparison);
Object left = ExpressionInterpreter.expressionOptimizer(comparison.getLeft(), metadata, session, expressionTypes).optimize(NoOpSymbolResolver.INSTANCE);
Object right = ExpressionInterpreter.expressionOptimizer(comparison.getRight(), metadata, session, expressionTypes).optimize(NoOpSymbolResolver.INSTANCE);
@@ -490,13 +488,15 @@ public final class DomainTranslator
private boolean isImplicitCoercion(Cast cast)
{
- IdentityLinkedHashMap<Expression, Type> expressionTypes = analyzeExpression(cast);
- return metadata.getTypeManager().canCoerce(expressionTypes.get(cast.getExpression()), expressionTypes.get(cast));
+ Map<NodeRef<Expression>, Type> expressionTypes = analyzeExpression(cast);
+ Type actualType = expressionTypes.get(NodeRef.of(cast.getExpression()));
+ Type expectedType = expressionTypes.get(NodeRef.<Expression>of(cast));
+ return metadata.getTypeManager().canCoerce(actualType, expectedType);
}
- private IdentityLinkedHashMap<Expression, Type> analyzeExpression(Expression expression)
+ private Map<NodeRef<Expression>, Type> analyzeExpression(Expression expression)
{
- return NodeRefCollections.toIdentityMap(ExpressionAnalyzer.getExpressionTypes(session, metadata, new SqlParser(), types, expression, emptyList() /* parameters already replaced */));
+ return ExpressionAnalyzer.getExpressionTypes(session, metadata, new SqlParser(), types, expression, emptyList() /* parameters already replaced */);
}
private static ExtractionResult createComparisonExtractionResult(ComparisonExpressionType comparisonType, Symbol column, Type type, @Nullable Object value, boolean complement)
@@ -752,8 +752,8 @@ public final class DomainTranslator
private static Type typeOf(Expression expression, Session session, Metadata metadata, Map<Symbol, Type> types)
{
- IdentityLinkedHashMap<Expression, Type> expressionTypes = NodeRefCollections.toIdentityMap(ExpressionAnalyzer.getExpressionTypes(session, metadata, new SqlParser(), types, expression, emptyList() /* parameters already replaced */));
- return expressionTypes.get(expression);
+ Map<NodeRef<Expression>, Type> expressionTypes = ExpressionAnalyzer.getExpressionTypes(session, metadata, new SqlParser(), types, expression, emptyList() /* parameters already replaced */);
+ return expressionTypes.get(NodeRef.of(expression));
}
private static class NormalizedSimpleComparison
