@Override protected Type visitInPredicate(InPredicate node, AnalysisContext context) { Expression value = node.getValue(); process(value, context); Expression valueList = node.getValueList(); process(valueList, context); if (valueList instanceof InListExpression) { InListExpression inListExpression = (InListExpression) valueList; coerceToSingleType( context, "IN value and list items must be the same type: %s", ImmutableList.<Expression>builder() .add(value) .addAll(inListExpression.getValues()) .build()); } else if (valueList instanceof SubqueryExpression) { coerceToSingleType( context, node, "value and result of subquery must be of the same type for IN expression: %s vs %s", value, valueList); subqueryInPredicates.add(node); } expressionTypes.put(node, BOOLEAN); return BOOLEAN; }
@Override protected Type visitInListExpression(InListExpression node, AnalysisContext context) { Type type = coerceToSingleType( context, "All IN list values must be the same type: %s", node.getValues()); expressionTypes.put(node, type); return type; // TODO: this really should a be relation type }
@Override protected String visitInListExpression(InListExpression node, Boolean unmangleNames) { return "(" + joinExpressions(node.getValues(), unmangleNames) + ")"; }