Search in sources :

Example 21 with Type

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

the class TableElementTest method shouldReturnSingleHeaderKeyConstraint.

@Test
public void shouldReturnSingleHeaderKeyConstraint() {
    // Given:
    final TableElement valueElement = new TableElement(NAME, new Type(SqlTypes.STRING), HEADER_SINGLE_KEY_CONSTRAINT);
    // Then:
    assertThat(valueElement.getConstraints(), is(HEADER_SINGLE_KEY_CONSTRAINT));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) Test(org.junit.Test)

Example 22 with Type

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

the class TableElementTest method shouldReturnPrimaryKey.

@Test
public void shouldReturnPrimaryKey() {
    // Given:
    final TableElement valueElement = new TableElement(NAME, new Type(SqlTypes.STRING), PRIMARY_KEY_CONSTRAINT);
    // Then:
    assertThat(valueElement.getConstraints(), is(PRIMARY_KEY_CONSTRAINT));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) Test(org.junit.Test)

Example 23 with Type

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

the class SqlTypeParserTest method shouldGetTypeFromStructWithTwoFields.

@Test
public void shouldGetTypeFromStructWithTwoFields() {
    // Given:
    final String schemaString = "STRUCT<A VARCHAR, B INT>";
    // When:
    final Type type = parser.parse(schemaString);
    // Then:
    assertThat(type, is(new Type(SqlStruct.builder().field("A", SqlTypes.STRING).field("B", SqlTypes.INTEGER).build())));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 24 with Type

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

the class SqlTypeParserTest method shouldReturnCustomTypeOnUnknownTypeName.

@Test
public void shouldReturnCustomTypeOnUnknownTypeName() {
    // Given:
    final String schemaString = "SHAKESPEARE";
    when(typeRegistry.resolveType(schemaString)).thenReturn(Optional.of(SqlTypes.STRING));
    // When:
    final Type type = parser.parse(schemaString);
    // Then:
    assertThat(type.getSqlType(), is(SqlTypes.STRING));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 25 with Type

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

the class SqlTypeParserTest method shouldGetTypeFromEmptyStruct.

@Test
public void shouldGetTypeFromEmptyStruct() {
    // Given:
    final String schemaString = SqlTypes.struct().build().toString();
    // When:
    final Type type = parser.parse(schemaString);
    // Then:
    assertThat(type, is(new Type(SqlTypes.struct().build())));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

Type (io.confluent.ksql.execution.expression.tree.Type)73 Test (org.junit.Test)71 SqlPrimitiveType (io.confluent.ksql.schema.ksql.types.SqlPrimitiveType)23 DataSourceType (io.confluent.ksql.metastore.model.DataSource.DataSourceType)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Cast (io.confluent.ksql.execution.expression.tree.Cast)13 CreateStream (io.confluent.ksql.parser.tree.CreateStream)13 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)12 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)12 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)12 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)12 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)12 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)12 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)12 Expression (io.confluent.ksql.execution.expression.tree.Expression)12 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)12 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)12 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)12 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)12 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)12