use of io.confluent.ksql.name.ColumnName 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)));
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class GenericRecordFactoryTest method shouldThrowOnTypeMismatchCannotCoerce.
@Test
public void shouldThrowOnTypeMismatchCannotCoerce() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(KEY, SqlTypes.STRING).valueColumn(COL0, SqlTypes.INTEGER).build();
final List<ColumnName> names = ImmutableList.of(KEY, COL0);
final Expression exp = new StringLiteral("a");
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> recordFactory.build(names, ImmutableList.of(exp, exp), schema, DataSourceType.KSTREAM));
// Then:
assertThat(e.getMessage(), containsString("Expected type"));
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class GenericRecordFactoryTest method shouldBuildPartialColumns.
@Test
public void shouldBuildPartialColumns() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(KEY, SqlTypes.STRING).valueColumn(COL0, SqlTypes.STRING).valueColumn(COL1, SqlTypes.STRING).build();
final List<ColumnName> names = ImmutableList.of(KEY, COL0);
final Expression exp = new StringLiteral("a");
// When:
final KsqlGenericRecord record = recordFactory.build(names, ImmutableList.of(exp, exp), schema, DataSourceType.KSTREAM);
// Then:
assertThat(record, is(KsqlGenericRecord.of(GenericKey.genericKey("a"), GenericRow.genericRow("a", null), 0)));
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class GenericRecordFactoryTest method shouldThrowOnTableMissingKey.
@Test
public void shouldThrowOnTableMissingKey() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(KEY, SqlTypes.STRING).valueColumn(COL0, SqlTypes.STRING).valueColumn(COL1, SqlTypes.STRING).build();
final List<ColumnName> names = ImmutableList.of(COL0, COL1);
final Expression exp = new StringLiteral("a");
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> recordFactory.build(names, ImmutableList.of(exp, exp), schema, DataSourceType.KTABLE));
// Then:
assertThat(e.getMessage(), containsString("Value for primary key column"));
}
use of io.confluent.ksql.name.ColumnName in project ksql by confluentinc.
the class GenericRecordFactoryTest method shouldThrowOnColumnMismatch.
@Test
public void shouldThrowOnColumnMismatch() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(KEY, SqlTypes.STRING).valueColumn(COL0, SqlTypes.STRING).valueColumn(COL1, SqlTypes.STRING).build();
final List<ColumnName> names = ImmutableList.of(KEY, COL0, COL1);
final Expression exp = new StringLiteral("a");
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> recordFactory.build(names, ImmutableList.of(exp, exp), schema, DataSourceType.KSTREAM));
// Then:
assertThat(e.getMessage(), containsString("Expected a value for each column"));
}
Aggregations