use of io.confluent.ksql.schema.ksql.Column in project ksql by confluentinc.
the class SchemaKStreamTest method buildJoinSchema.
@SuppressWarnings("rawtypes")
private LogicalSchema buildJoinSchema(final KsqlStream stream) {
final LogicalSchema.Builder builder = LogicalSchema.builder();
builder.keyColumns(stream.getSchema().key());
for (final Column c : stream.getSchema().value()) {
builder.valueColumn(ColumnNames.generatedJoinColumnAlias(stream.getName(), c.name()), c.type());
}
return builder.build();
}
use of io.confluent.ksql.schema.ksql.Column in project ksql by confluentinc.
the class AssertExecutor method fromGenericRow.
private static TabularRow fromGenericRow(final boolean expected, final DataSource source, final KsqlGenericRecord row) {
final GenericRow contents = new GenericRow();
contents.append(expected ? "EXPECTED" : "ACTUAL");
contents.appendAll(row.key.values());
contents.append(row.ts);
if (row.value == null) {
for (final Column ignored : source.getSchema().value()) {
contents.append("<TOMBSTONE>");
}
} else {
contents.appendAll(row.value.values());
}
return TabularRow.createRow(80, contents.values(), false, 0);
}
use of io.confluent.ksql.schema.ksql.Column in project ksql by confluentinc.
the class AssertExecutor method throwAssertionError.
private static void throwAssertionError(final String message, final DataSource dataSource, final KsqlGenericRecord expected, final List<KsqlGenericRecord> actual) {
final List<Column> columns = ImmutableList.<Column>builder().add(Column.of(ColumnName.of("."), SqlTypes.STRING, Namespace.KEY, 0)).add(Column.of(SystemColumns.ROWTIME_NAME, SqlTypes.BIGINT, Namespace.KEY, 0)).addAll(dataSource.getSchema().columns()).build();
final TabularRow headerRow = TabularRow.createHeader(80, columns, false, 0);
final StringBuilder actualRows = new StringBuilder();
actual.forEach(a -> actualRows.append(fromGenericRow(false, dataSource, a)).append('\n'));
throw new AssertionError(String.format("%s%n%s%n%s%n%s", message, headerRow, fromGenericRow(true, dataSource, expected), actualRows.toString()));
}
use of io.confluent.ksql.schema.ksql.Column in project ksql by confluentinc.
the class JoinNodeTest method prependAlias.
private static LogicalSchema prependAlias(final SourceName alias, final LogicalSchema schema) {
final LogicalSchema.Builder builder = LogicalSchema.builder();
builder.keyColumns(schema.key());
for (final Column c : schema.value()) {
builder.valueColumn(ColumnNames.generatedJoinColumnAlias(alias, c.name()), c.type());
}
return builder.build();
}
use of io.confluent.ksql.schema.ksql.Column in project ksql by confluentinc.
the class DefaultSchemaInjector method getCreateAsKeySchema.
private Optional<SchemaAndId> getCreateAsKeySchema(final ConfiguredStatement<CreateAsSelect> statement, final CreateSourceCommand createSourceCommand) {
final CreateAsSelect csStmt = statement.getStatement();
final CreateSourceAsProperties props = csStmt.getProperties();
final FormatInfo keyFormat = createSourceCommand.getFormats().getKeyFormat();
if (!shouldInferSchema(props.getKeySchemaId(), statement, keyFormat, true)) {
return Optional.empty();
}
// until we support user-configuration of single key wrapping/unwrapping, we choose
// to have key schema inference always result in an unwrapped key
final SerdeFeatures serdeFeatures = SerdeFeaturesFactory.buildKeyFeatures(FormatFactory.of(keyFormat), true);
if (!shouldInferSchema(props.getKeySchemaId(), statement, keyFormat, true)) {
return Optional.empty();
}
final SchemaAndId schemaAndId = getSchema(props.getKafkaTopic(), props.getKeySchemaId(), keyFormat, serdeFeatures, statement.getStatementText(), true);
final List<Column> tableColumns = createSourceCommand.getSchema().key();
checkColumnsCompatibility(props.getKeySchemaId(), tableColumns, schemaAndId.columns, true);
return Optional.of(schemaAndId);
}
Aggregations