Search in sources :

Example 36 with ArithmeticBinaryExpression

use of io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression in project ksql by confluentinc.

the class ExpressionParserTest method shouldParseExpression.

@Test
public void shouldParseExpression() {
    // When:
    final Expression parsed = ExpressionParser.parseExpression("1 + 2");
    // Then:
    assertThat(parsed, equalTo(new ArithmeticBinaryExpression(parsed.getLocation(), Operator.ADD, ONE, TWO)));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) TumblingWindowExpression(io.confluent.ksql.execution.windows.TumblingWindowExpression) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) KsqlWindowExpression(io.confluent.ksql.execution.windows.KsqlWindowExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) SelectExpression(io.confluent.ksql.execution.plan.SelectExpression) ExpressionParser.parseSelectExpression(io.confluent.ksql.parser.ExpressionParser.parseSelectExpression) Test(org.junit.Test)

Example 37 with ArithmeticBinaryExpression

use of io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression in project ksql by confluentinc.

the class PartitionByParamsFactoryTest method shouldAppendNewKeyColumnToValueIfPartitioningByKeyExpression.

@Test
public void shouldAppendNewKeyColumnToValueIfPartitioningByKeyExpression() {
    // Given:
    final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("-foo")))).getMapper();
    final ImmutableList<Object> originals = ImmutableList.copyOf(value.values());
    // When:
    final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, value);
    // Then:
    assertThat(result.value, is(GenericRow.fromList(originals).append(OLD_KEY + "-foo")));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) GenericRow(io.confluent.ksql.GenericRow) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) GenericKey(io.confluent.ksql.GenericKey) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Aggregations

ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)37 Test (org.junit.Test)37 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)20 Expression (io.confluent.ksql.execution.expression.tree.Expression)20 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)19 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)19 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)19 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)19 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)19 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)19 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)17 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)16 LambdaFunctionCall (io.confluent.ksql.execution.expression.tree.LambdaFunctionCall)16 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)15 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)15 LambdaVariable (io.confluent.ksql.execution.expression.tree.LambdaVariable)15 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)13 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 SqlType (io.confluent.ksql.schema.ksql.types.SqlType)9