use of io.confluent.ksql.execution.expression.tree.IntervalUnit in project ksql by confluentinc.
the class AstBuilderTest method shouldBuildIntervalUnit.
@Test
public void shouldBuildIntervalUnit() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TIMESTAMPADD(MINUTES, 5, Col4) FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(new FunctionCall(FunctionName.of("TIMESTAMPADD"), ImmutableList.of(new IntervalUnit(TimeUnit.MINUTES), new IntegerLiteral(5), column("COL4"))), Optional.empty())))));
}
use of io.confluent.ksql.execution.expression.tree.IntervalUnit in project ksql by confluentinc.
the class SqlToJavaVisitorTest method shouldGenerateCorrectCodeForIntervalUnit.
@Test
public void shouldGenerateCorrectCodeForIntervalUnit() {
// Given:
final IntervalUnit intervalUnit = new IntervalUnit(TimeUnit.DAYS);
// When:
final String java = sqlToJavaVisitor.process(intervalUnit);
// Then:
assertThat(java, containsString("TimeUnit.DAYS"));
}
use of io.confluent.ksql.execution.expression.tree.IntervalUnit in project ksql by confluentinc.
the class InterpretedExpressionTest method shouldHandleFunctionCalls_intervalParam.
@Test
public void shouldHandleFunctionCalls_intervalParam() {
// Given:
final UdfFactory udfFactory = mock(UdfFactory.class);
final KsqlScalarFunction udf = mock(KsqlScalarFunction.class);
when(udf.newInstance(any())).thenReturn(new toMillisUdf());
givenUdf("FOO", udfFactory, udf);
when(udf.parameters()).thenReturn(ImmutableList.of(IntervalUnitType.INSTANCE, IntegerType.INSTANCE));
// When:
InterpretedExpression interpreter1 = interpreter(new FunctionCall(FunctionName.of("FOO"), ImmutableList.of(new IntervalUnit(TimeUnit.SECONDS), new IntegerLiteral(1))));
final Object object = interpreter1.evaluate(ROW);
// Then:
assertThat(object, is(1000));
}
use of io.confluent.ksql.execution.expression.tree.IntervalUnit in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteIntervalUnitUsingPlugin.
@Test
public void shouldRewriteIntervalUnitUsingPlugin() {
// Given:
final IntervalUnit expression = new IntervalUnit(TimeUnit.DAYS);
shouldRewriteUsingPlugin(expression);
}
Aggregations