Search in sources :

Example 1 with SqlPrimitiveType

use of io.confluent.ksql.schema.ksql.types.SqlPrimitiveType in project ksql by confluentinc.

the class SqlTypeWalkerTest method shouldVisitBoolean.

@Test
public void shouldVisitBoolean() {
    // Given:
    final SqlPrimitiveType type = SqlTypes.BOOLEAN;
    when(visitor.visitBoolean(any())).thenReturn("Expected");
    // When:
    final String result = SqlTypeWalker.visit(type, visitor);
    // Then:
    verify(visitor).visitBoolean(same(type));
    assertThat(result, is("Expected"));
}
Also used : SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with SqlPrimitiveType

use of io.confluent.ksql.schema.ksql.types.SqlPrimitiveType in project ksql by confluentinc.

the class SqlTypeWalkerTest method shouldVisitInt.

@Test
public void shouldVisitInt() {
    // Given:
    final SqlPrimitiveType type = SqlTypes.INTEGER;
    when(visitor.visitInt(any())).thenReturn("Expected");
    // When:
    final String result = SqlTypeWalker.visit(type, visitor);
    // Then:
    verify(visitor).visitInt(same(type));
    assertThat(result, is("Expected"));
}
Also used : SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with SqlPrimitiveType

use of io.confluent.ksql.schema.ksql.types.SqlPrimitiveType in project ksql by confluentinc.

the class SqlTypeWalkerTest method shouldVisitTimestamp.

@Test
public void shouldVisitTimestamp() {
    // Given:
    final SqlPrimitiveType type = SqlTypes.TIMESTAMP;
    when(visitor.visitTimestamp(any())).thenReturn("Expected");
    // When:
    final String result = SqlTypeWalker.visit(type, visitor);
    // Then:
    verify(visitor).visitTimestamp(same(type));
    assertThat(result, is("Expected"));
}
Also used : SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with SqlPrimitiveType

use of io.confluent.ksql.schema.ksql.types.SqlPrimitiveType in project ksql by confluentinc.

the class TimestampExtractionPolicyFactoryTest method shouldThrowIfTimestampFieldTypeIsNotLongOrTimestampOrString.

@Test
public void shouldThrowIfTimestampFieldTypeIsNotLongOrTimestampOrString() {
    final Set<SqlPrimitiveType> allowedTypes = Sets.newHashSet(SqlTypes.BIGINT, SqlTypes.STRING, SqlTypes.TIMESTAMP);
    for (SqlPrimitiveType sqlType : SqlTypes.ALL) {
        if (allowedTypes.contains(sqlType)) {
            continue;
        }
        // Given:
        final String field = "blah_" + sqlType.toString();
        final LogicalSchema schema = schemaBuilder2.valueColumn(ColumnName.of(field.toUpperCase()), sqlType).build();
        // When:
        assertThrows(KsqlException.class, () -> TimestampExtractionPolicyFactory.create(ksqlConfig, schema, Optional.of(new TimestampColumn(ColumnName.of(field), Optional.empty()))));
    }
}
Also used : SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) TimestampColumn(io.confluent.ksql.execution.timestamp.TimestampColumn) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 5 with SqlPrimitiveType

use of io.confluent.ksql.schema.ksql.types.SqlPrimitiveType in project ksql by confluentinc.

the class SqlTypeWalkerTest method shouldVisitBigInt.

@Test
public void shouldVisitBigInt() {
    // Given:
    final SqlPrimitiveType type = SqlTypes.BIGINT;
    when(visitor.visitBigInt(any())).thenReturn("Expected");
    // When:
    final String result = SqlTypeWalker.visit(type, visitor);
    // Then:
    verify(visitor).visitBigInt(same(type));
    assertThat(result, is("Expected"));
}
Also used : SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

SqlPrimitiveType (io.confluent.ksql.schema.ksql.types.SqlPrimitiveType)10 Test (org.junit.Test)9 Matchers.containsString (org.hamcrest.Matchers.containsString)8 TimestampColumn (io.confluent.ksql.execution.timestamp.TimestampColumn)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1 SqlArgument (io.confluent.ksql.schema.ksql.SqlArgument)1 SqlBaseType (io.confluent.ksql.schema.ksql.types.SqlBaseType)1 Field (io.confluent.ksql.schema.ksql.types.SqlStruct.Field)1 KsqlException (io.confluent.ksql.util.KsqlException)1 ArrayList (java.util.ArrayList)1