Search in sources :

Example 76 with StringLiteral

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

the class CreateSourcePropertiesTest method shouldThrowOnConstructionOnUnknownWindowType.

@Test
public void shouldThrowOnConstructionOnUnknownWindowType() {
    // Given:
    final Map<String, Literal> props = ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CreateConfigs.WINDOW_TYPE_PROPERTY, new StringLiteral("Unknown")).build();
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(props));
    // Then:
    assertThat(e.getMessage(), containsString("Invalid value Unknown for property WINDOW_TYPE: " + "String must be one of: SESSION, HOPPING, TUMBLING, null"));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 77 with StringLiteral

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

the class CreateSourcePropertiesTest method shouldThrowOnSessionWindowWithSize.

@Test
public void shouldThrowOnSessionWindowWithSize() {
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(WINDOW_TYPE_PROPERTY, new StringLiteral("SESSION")).put(WINDOW_SIZE_PROPERTY, new StringLiteral("2 MILLISECONDS")).build()));
    // Then:
    assertThat(e.getMessage(), containsString("'WINDOW_SIZE' should not be set for SESSION windows."));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 78 with StringLiteral

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

the class CreateSourcePropertiesTest method shouldSetValidSchemaIds.

@Test
public void shouldSetValidSchemaIds() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(KEY_SCHEMA_ID, new StringLiteral("1")).put(VALUE_SCHEMA_ID, new StringLiteral("2")).build());
    // Then:
    assertThat(properties.getKeySchemaId(), is(Optional.of(1)));
    assertThat(properties.getValueSchemaId(), is(Optional.of(2)));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) Test(org.junit.Test)

Example 79 with StringLiteral

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

the class CreateSourcePropertiesTest method shouldThrowOnTumblingWindowWithOutSize.

@Test
public void shouldThrowOnTumblingWindowWithOutSize() {
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(WINDOW_TYPE_PROPERTY, new StringLiteral("tumbling")).build()));
    // Then:
    assertThat(e.getMessage(), containsString("TUMBLING windows require 'WINDOW_SIZE' to be provided in the WITH clause. " + "For example: 'WINDOW_SIZE'='10 SECONDS'"));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 80 with StringLiteral

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

the class CreateSourcePropertiesTest method shouldSetSessionWindow.

@Test
public void shouldSetSessionWindow() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CreateConfigs.WINDOW_TYPE_PROPERTY, new StringLiteral("SESSION")).build());
    // Then:
    assertThat(properties.getWindowType(), is(Optional.of(WindowType.SESSION)));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)204 Test (org.junit.Test)199 Expression (io.confluent.ksql.execution.expression.tree.Expression)95 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)70 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)66 KsqlException (io.confluent.ksql.util.KsqlException)64 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)63 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)63 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)63 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)61 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)53 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)51 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)49 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)43 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)36 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)35 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)34 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)31 BooleanLiteral (io.confluent.ksql.execution.expression.tree.BooleanLiteral)28 Matchers.containsString (org.hamcrest.Matchers.containsString)27