Search in sources :

Example 41 with IntegerLiteral

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

the class DefaultSchemaInjectorTest method shouldThrowIfCtasKeyTableElementsNotCompatibleWrongKeyType.

@Test
public void shouldThrowIfCtasKeyTableElementsNotCompatibleWrongKeyType() {
    // Given:
    givenFormatsAndProps("protobuf", null, ImmutableMap.of("KEY_SCHEMA_ID", new IntegerLiteral(42)));
    givenDDLSchemaAndFormats(LOGICAL_SCHEMA_INT_KEY, "protobuf", "avro", SerdeFeature.WRAP_SINGLES, SerdeFeature.UNWRAP_SINGLES);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> injector.inject(ctasStatement));
    // Then:
    assertThat(e.getMessage(), containsString("The following key columns are changed, missing or reordered: " + "[`key` INTEGER KEY]. Schema from schema registry is [`key` STRING KEY]"));
}
Also used : IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 42 with IntegerLiteral

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

the class DefaultSchemaInjectorTest method shouldThrowIfValueFormatDoesNotSupportSchemaIdInference.

@Test
public void shouldThrowIfValueFormatDoesNotSupportSchemaIdInference() {
    // Given
    givenKeyButNotValueInferenceSupported(ImmutableMap.of("value_schema_id", new IntegerLiteral(123), "WRAP_SINGLE_VALUE", new BooleanLiteral(true)));
    when(cs.getElements()).thenReturn(SOME_KEY_ELEMENTS_STREAM);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> injector.inject(csStatement));
    // Then:
    assertThat(e.getMessage(), containsString("VALUE_FORMAT should support schema inference when VALUE_SCHEMA_ID is provided. " + "Current format is DELIMITED."));
}
Also used : BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 43 with IntegerLiteral

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

the class DefaultSchemaInjectorTest method shouldThrowIfCsasKeyFormatDoesnotSupportInference.

@Test
public void shouldThrowIfCsasKeyFormatDoesnotSupportInference() {
    // Given:
    givenFormatsAndProps("kafka", null, ImmutableMap.of("KEY_SCHEMA_ID", new IntegerLiteral(42)));
    givenDDLSchemaAndFormats(LOGICAL_SCHEMA, "kafka", "avro", SerdeFeature.WRAP_SINGLES, SerdeFeature.UNWRAP_SINGLES);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> injector.inject(csasStatement));
    // Then:
    assertThat(e.getMessage(), containsString("KEY_FORMAT should support schema inference when " + "KEY_SCHEMA_ID is provided. Current format is KAFKA."));
}
Also used : IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 44 with IntegerLiteral

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

the class DefaultSchemaInjectorTest method shouldThrowIfCsasKeyTableElementsNotCompatibleReorderedValue.

@Test
public void shouldThrowIfCsasKeyTableElementsNotCompatibleReorderedValue() {
    // Given:
    givenFormatsAndProps("kafka", "avro", ImmutableMap.of("VALUE_SCHEMA_ID", new IntegerLiteral(42)));
    givenDDLSchemaAndFormats(LOGICAL_SCHEMA_VALUE_REORDERED, "kafka", "avro", SerdeFeature.UNWRAP_SINGLES, SerdeFeature.UNWRAP_SINGLES);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> injector.inject(csasStatement));
    // Then:
    assertThat(e.getMessage(), containsString("The following value columns are changed, missing or reordered: " + "[`bigIntField` BIGINT, `intField` INTEGER]. Schema from schema registry is [" + "`intField` INTEGER, " + "`bigIntField` BIGINT, " + "`doubleField` DOUBLE, " + "`stringField` STRING, " + "`booleanField` BOOLEAN, " + "`arrayField` ARRAY<INTEGER>, " + "`mapField` MAP<STRING, BIGINT>, " + "`structField` STRUCT<`s0` BIGINT>, " + "`decimalField` DECIMAL(4, 2)]"));
}
Also used : IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 45 with IntegerLiteral

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

the class DefaultSchemaInjectorTest method shouldThrowIfCsasValueFormatDoesnotSupportInference.

@Test
public void shouldThrowIfCsasValueFormatDoesnotSupportInference() {
    // Given:
    givenFormatsAndProps(null, "kafka", ImmutableMap.of("VALUE_SCHEMA_ID", new IntegerLiteral(42)));
    givenDDLSchemaAndFormats(LOGICAL_SCHEMA, "kafka", "delimited", SerdeFeature.UNWRAP_SINGLES, SerdeFeature.UNWRAP_SINGLES);
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> injector.inject(csasStatement));
    // Then:
    assertThat(e.getMessage(), containsString("VALUE_FORMAT should support schema inference when " + "VALUE_SCHEMA_ID is provided. Current format is DELIMITED."));
}
Also used : IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Aggregations

IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)150 Test (org.junit.Test)146 Expression (io.confluent.ksql.execution.expression.tree.Expression)111 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)85 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)81 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)66 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)62 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)61 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)61 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)60 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)46 KsqlException (io.confluent.ksql.util.KsqlException)46 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)45 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)42 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)38 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)38 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)30 LambdaFunctionCall (io.confluent.ksql.execution.expression.tree.LambdaFunctionCall)24 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)23 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)23