Search in sources :

Example 1 with BooleanLiteral

use of io.confluent.ksql.parser.tree.BooleanLiteral in project ksql by confluentinc.

the class ProjectNodeTest method shouldThrowKsqlExcptionIfSchemaSizeDoesntMatchProjection.

@Test(expected = KsqlException.class)
public void shouldThrowKsqlExcptionIfSchemaSizeDoesntMatchProjection() {
    mockSourceNode();
    EasyMock.replay(source, stream);
    final ProjectNode node = new ProjectNode(new PlanNodeId("1"), source, SchemaBuilder.struct().field("field1", Schema.STRING_SCHEMA).field("field2", Schema.STRING_SCHEMA).build(), Collections.singletonList(new BooleanLiteral("true")));
    node.buildStream(builder, ksqlConfig, kafkaTopicClient, functionRegistry, props, new MockSchemaRegistryClient());
}
Also used : BooleanLiteral(io.confluent.ksql.parser.tree.BooleanLiteral) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) Test(org.junit.Test)

Example 2 with BooleanLiteral

use of io.confluent.ksql.parser.tree.BooleanLiteral in project ksql by confluentinc.

the class ProjectNodeTest method shouldCreateProjectionWithFieldNameExpressionPairs.

@Test
public void shouldCreateProjectionWithFieldNameExpressionPairs() {
    mockSourceNode();
    final BooleanLiteral trueExpression = new BooleanLiteral("true");
    final BooleanLiteral falseExpression = new BooleanLiteral("false");
    EasyMock.expect(stream.select(Arrays.asList(new Pair<>("field1", trueExpression), new Pair<>("field2", falseExpression)))).andReturn(stream);
    EasyMock.replay(source, stream);
    final ProjectNode node = new ProjectNode(new PlanNodeId("1"), source, SchemaBuilder.struct().field("field1", Schema.STRING_SCHEMA).field("field2", Schema.STRING_SCHEMA).build(), Arrays.asList(trueExpression, falseExpression));
    node.buildStream(builder, ksqlConfig, kafkaTopicClient, functionRegistry, props, new MockSchemaRegistryClient());
    EasyMock.verify(stream);
}
Also used : BooleanLiteral(io.confluent.ksql.parser.tree.BooleanLiteral) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) Pair(io.confluent.ksql.util.Pair) Test(org.junit.Test)

Aggregations

MockSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient)2 BooleanLiteral (io.confluent.ksql.parser.tree.BooleanLiteral)2 Test (org.junit.Test)2 Pair (io.confluent.ksql.util.Pair)1