protected Node visitInListExpression(final InListExpression node, final Object context) { // use an if/else block here (instead of isPresent.map(...).orElse(...)) so only one object // gets instantiated (issue #1784) if (node.getLocation().isPresent()) { return new InListExpression(node.getLocation().get(), node.getValues().stream() .map(value -> (Expression) process(value, context)) .collect(Collectors.toList()) ); } else { return new InListExpression(node.getValues().stream() .map(value -> (Expression) process(value, context)) .collect(Collectors.toList()) ); } }
@Override public Node visitInList(final SqlBaseParser.InListContext context) { Expression result = new InPredicate( getLocation(context), (Expression) visit(context.value), new InListExpression(getLocation(context), visit(context.expression(), Expression.class)) ); if (context.NOT() != null) { result = new NotExpression(getLocation(context), result); } return result; }
@Override protected R visitInListExpression(final InListExpression node, final C context) { for (final Expression value : node.getValues()) { process(value, context); } return null; }
@Test public void shouldFormatInListExpression() { assertThat(ExpressionFormatter.formatExpression(new InListExpression(Collections.singletonList(new StringLiteral("a")))), equalTo("('a')")); }
@Override protected R visitInListExpression(final InListExpression node, final C context) { for (final Expression value : node.getValues()) { process(value, context); } return null; }
@Override protected String visitInListExpression( final InListExpression node, final Boolean unmangleNames) { return "(" + joinExpressions(node.getValues(), unmangleNames) + ")"; }