private static NodeLocation getLocation(final Token token) { requireNonNull(token, "token is null"); return new NodeLocation(token.getLine(), token.getCharPositionInLine()); } }
public ParsingException(final String message, final NodeLocation nodeLocation) { this(message, null, nodeLocation.getLineNumber(), nodeLocation.getColumnNumber()); }
private static NodeLocation getLocation(final Token token) { requireNonNull(token, "token is null"); return new NodeLocation(token.getLine(), token.getCharPositionInLine()); }
private static PrintTopic printTopic(final String name, final boolean fromBeginning) { return new PrintTopic( new NodeLocation(0, 1), QualifiedName.of(name), fromBeginning, Optional.empty() ); }
@Test public void shouldFormatFunctionWithDistinct() { final FunctionCall functionCall = new FunctionCall(new NodeLocation(1, 1), QualifiedName.of("function", "COUNT"), true, Collections.singletonList(new StringLiteral("name"))); assertThat(ExpressionFormatter.formatExpression(functionCall), equalTo("function.COUNT(DISTINCT 'name')")); }
@Test public void shouldFormatFunctionCallWithWindow() { final FunctionCall functionCall = new FunctionCall(new NodeLocation(1, 1), QualifiedName.of("function"), Optional.of(new Window("window", new WindowExpression("blah", new TumblingWindowExpression(1L, TimeUnit.SECONDS)))), false, Collections.singletonList(new StringLiteral("name"))); assertThat(ExpressionFormatter.formatExpression(functionCall), equalTo("function('name') OVER WINDOW WINDOW blah TUMBLING ( SIZE 1 SECONDS ) ")); }
new StringLiteral("left.col0"), new StringLiteral("right.col0"))); location = new NodeLocation(0, 0);