Search in sources :

Example 26 with Type

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

the class SqlTypeParserTest method shouldGetTypeFromIntArray.

@Test
public void shouldGetTypeFromIntArray() {
    // Given:
    final String schemaString = "ARRAY<INT>";
    // When:
    final Type type = parser.parse(schemaString);
    // Then:
    assertThat(type, is(new Type(SqlTypes.array(SqlTypes.INTEGER))));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 27 with Type

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

the class CommandFactoriesTest method shouldCreateCommandForCreateTable.

@Test
public void shouldCreateCommandForCreateTable() {
    // Given:
    final CreateTable statement = new CreateTable(SOME_NAME, TableElements.of(tableElement("COL1", new Type(SqlTypes.BIGINT)), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, false);
    // When:
    final DdlCommand result = commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, emptyMap()));
    // Then:
    assertThat(result, is(createTableCommand));
    verify(createSourceFactory).createTableCommand(statement, ksqlConfig);
}
Also used : RegisterType(io.confluent.ksql.parser.tree.RegisterType) SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) DataSourceType(io.confluent.ksql.metastore.model.DataSource.DataSourceType) SqlBaseType(io.confluent.ksql.schema.ksql.types.SqlBaseType) Type(io.confluent.ksql.execution.expression.tree.Type) DropType(io.confluent.ksql.parser.DropType) DdlCommand(io.confluent.ksql.execution.ddl.commands.DdlCommand) CreateTable(io.confluent.ksql.parser.tree.CreateTable) Test(org.junit.Test)

Example 28 with Type

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

the class CommandFactoriesTest method shouldCreateCommandForCreateTableWithOverriddenProperties.

@Test
public void shouldCreateCommandForCreateTableWithOverriddenProperties() {
    // Given:
    final CreateTable statement = new CreateTable(SOME_NAME, TableElements.of(tableElement("COL1", new Type(SqlTypes.BIGINT)), tableElement("COL2", new Type(SqlTypes.STRING))), false, true, withProperties, false);
    // When:
    commandFactories.create(sqlExpression, statement, SessionConfig.of(ksqlConfig, OVERRIDES));
    // Then:
    verify(createSourceFactory).createTableCommand(statement, ksqlConfig.cloneWithPropertyOverwrite(OVERRIDES));
}
Also used : RegisterType(io.confluent.ksql.parser.tree.RegisterType) SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) DataSourceType(io.confluent.ksql.metastore.model.DataSource.DataSourceType) SqlBaseType(io.confluent.ksql.schema.ksql.types.SqlBaseType) Type(io.confluent.ksql.execution.expression.tree.Type) DropType(io.confluent.ksql.parser.DropType) CreateTable(io.confluent.ksql.parser.tree.CreateTable) Test(org.junit.Test)

Example 29 with Type

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

the class SchemaParserTest method shouldParseQuotedSchema.

@Test
public void shouldParseQuotedSchema() {
    // Given:
    final String schema = "`END` VARCHAR";
    // When:
    final TableElements elements = parser.parse(schema);
    // Then:
    assertThat(elements, hasItem(new TableElement(ColumnName.of("END"), new Type(SqlTypes.STRING))));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) TableElements(io.confluent.ksql.parser.tree.TableElements) Matchers.containsString(org.hamcrest.Matchers.containsString) TableElement(io.confluent.ksql.parser.tree.TableElement) Test(org.junit.Test)

Example 30 with Type

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

the class SchemaParserTest method shouldParseValidSchemaWithPrimaryKeyField.

@Test
public void shouldParseValidSchemaWithPrimaryKeyField() {
    // Given:
    final String schema = "K STRING PRIMARY KEY, bar INT";
    // When:
    final TableElements elements = parser.parse(schema);
    // Then:
    assertThat(elements, contains(new TableElement(ColumnName.of("K"), new Type(SqlTypes.STRING), PRIMARY_KEY_CONSTRAINT), new TableElement(BAR, new Type(SqlTypes.INTEGER))));
}
Also used : Type(io.confluent.ksql.execution.expression.tree.Type) TableElements(io.confluent.ksql.parser.tree.TableElements) Matchers.containsString(org.hamcrest.Matchers.containsString) TableElement(io.confluent.ksql.parser.tree.TableElement) 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