Search in sources :

Example 1 with NullLiteral

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

the class QueryFilterNodeTest method shouldExtractKeyValueFromNullLiteral.

@Test
public void shouldExtractKeyValueFromNullLiteral() {
    // Given:
    final Expression expression = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new NullLiteral());
    // When:
    final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, false, plannerOptions));
    // Then:
    assertThat(e.getMessage(), containsString("Primary key columns can not be NULL: (K = null)"));
}
Also used : ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) LogicalBinaryExpression(io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) KsqlException(io.confluent.ksql.util.KsqlException) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) Test(org.junit.Test)

Example 2 with NullLiteral

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

the class GenericRecordFactoryTest method shouldAcceptNullsForAnyColumn.

@Test
public void shouldAcceptNullsForAnyColumn() {
    // Given:
    final LogicalSchema schema = LogicalSchema.builder().keyColumn(KEY, SqlTypes.STRING).valueColumn(COL0, SqlTypes.BIGINT).build();
    final List<ColumnName> names = ImmutableList.of(KEY, COL0);
    // When:
    final KsqlGenericRecord record = recordFactory.build(names, ImmutableList.of(new NullLiteral(), new NullLiteral()), schema, DataSourceType.KSTREAM);
    // Then:
    assertThat(record, is(KsqlGenericRecord.of(GenericKey.genericKey((Object) null), GenericRow.genericRow((Object) null), 0)));
}
Also used : ColumnName(io.confluent.ksql.name.ColumnName) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) Test(org.junit.Test)

Example 3 with NullLiteral

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

the class PartitionByParamsFactoryTest method shouldBuildResultSchemaWhenPartitioningByNull.

@Test
public void shouldBuildResultSchemaWhenPartitioningByNull() {
    // Given:
    final List<Expression> partitionBy = ImmutableList.of(new NullLiteral());
    // When:
    final LogicalSchema resultSchema = PartitionByParamsFactory.buildSchema(SCHEMA, partitionBy, functionRegistry);
    // Then:
    assertThat(resultSchema, is(LogicalSchema.builder().valueColumn(COL1, SqlTypes.INTEGER).valueColumn(COL2, SqlTypes.INTEGER).valueColumn(COL3, COL3_TYPE).valueColumn(SystemColumns.ROWTIME_NAME, SqlTypes.BIGINT).valueColumn(COL0, SqlTypes.STRING).build()));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) Test(org.junit.Test)

Example 4 with NullLiteral

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

the class ExpressionTypeManagerTest method shouldThrowOnArrayAllNulls.

@Test
public void shouldThrowOnArrayAllNulls() {
    // Given:
    Expression expression = new CreateArrayExpression(ImmutableList.of(new NullLiteral()));
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
    // Then:
    assertThat(e.getMessage(), containsString("Cannot construct an array with all NULL elements"));
}
Also used : CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 5 with NullLiteral

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

the class ExpressionTypeManagerTest method shouldThrowOnMapOfNullValues.

@Test
public void shouldThrowOnMapOfNullValues() {
    // Given:
    Expression expression = new CreateMapExpression(ImmutableMap.of(new StringLiteral("foo"), new NullLiteral()));
    // When:
    final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
    // Then:
    assertThat(e.getMessage(), containsString("Cannot construct a map with all NULL values"));
}
Also used : CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Aggregations

NullLiteral (io.confluent.ksql.execution.expression.tree.NullLiteral)18 Test (org.junit.Test)17 Expression (io.confluent.ksql.execution.expression.tree.Expression)13 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)9 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)8 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)8 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)7 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)7 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)7 KsqlException (io.confluent.ksql.util.KsqlException)7 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)6 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)5 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)5 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)5 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)5 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)4 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)3 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)3 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)3 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)3