use of io.confluent.ksql.execution.expression.tree.StringLiteral 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.execution.expression.tree.StringLiteral 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.execution.expression.tree.StringLiteral 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"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class GenericRecordFactoryTest method shouldThrowOnInsertRowoffset.
@Test
public void shouldThrowOnInsertRowoffset() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(KEY, SqlTypes.STRING).valueColumn(COL0, SqlTypes.STRING).build();
final Expression exp = new StringLiteral("a");
when(ksqlConfig.getBoolean(KsqlConfig.KSQL_ROWPARTITION_ROWOFFSET_ENABLED)).thenReturn(true);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> recordFactory.build(ImmutableList.of(SystemColumns.ROWTIME_NAME, KEY, SystemColumns.ROWOFFSET_NAME), ImmutableList.of(new LongLiteral(1L), exp, exp), schema, DataSourceType.KSTREAM));
// Then:
assertThat(e.getMessage(), containsString("Inserting into column `ROWOFFSET` is not allowed."));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class GenericExpressionResolverTest method shouldParseDate.
@Test
public void shouldParseDate() {
// Given:
final SqlType type = SqlTypes.DATE;
final Expression exp = new StringLiteral("2021-01-09");
// When:
Object o = new GenericExpressionResolver(type, FIELD_NAME, registry, config, "insert value", false).resolve(exp);
// Then:
assertTrue(o instanceof Date);
assertThat(((Date) o).getTime(), is(1610150400000L));
}
Aggregations