use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class EntityUtilTest method shouldBuildCorrectArrayField.
@Test
public void shouldBuildCorrectArrayField() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field"), SqlTypes.array(SqlTypes.BIGINT)).build();
// When:
final List<FieldInfo> fields = EntityUtil.buildSourceSchemaEntity(schema);
// Then:
assertThat(fields, hasSize(1));
assertThat(fields.get(0).getName(), equalTo("field"));
assertThat(fields.get(0).getSchema().getTypeName(), equalTo("ARRAY"));
assertThat(fields.get(0).getSchema().getFields(), equalTo(Optional.empty()));
assertThat(fields.get(0).getSchema().getMemberSchema().get().getTypeName(), equalTo("BIGINT"));
}
use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class EntityUtilTest method shouldBuildCorrectStructField.
@Test
public void shouldBuildCorrectStructField() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field"), SqlTypes.struct().field("innerField", SqlTypes.STRING).build()).build();
// When:
final List<FieldInfo> fields = EntityUtil.buildSourceSchemaEntity(schema);
// Then:
assertThat(fields, hasSize(1));
assertThat(fields.get(0).getName(), equalTo("field"));
assertThat(fields.get(0).getSchema().getTypeName(), equalTo("STRUCT"));
assertThat(fields.get(0).getSchema().getFields().get().size(), equalTo(1));
final FieldInfo inner = fields.get(0).getSchema().getFields().get().get(0);
assertThat(inner.getSchema().getTypeName(), equalTo("STRING"));
assertThat(inner.getType(), equalTo(Optional.empty()));
assertThat(fields.get(0).getSchema().getMemberSchema(), equalTo(Optional.empty()));
}
use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class EntityUtilTest method shouldMaintainColumnOrder.
@Test
public void shouldMaintainColumnOrder() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field0"), SqlTypes.DOUBLE).keyColumn(ColumnName.of("field1"), SqlTypes.INTEGER).build();
// When:
final List<FieldInfo> fields = EntityUtil.buildSourceSchemaEntity(schema);
// Then:
assertThat(fields, hasSize(2));
assertThat(fields.get(0).getName(), equalTo("field0"));
assertThat(fields.get(0).getSchema().getTypeName(), equalTo("DOUBLE"));
assertThat(fields.get(1).getName(), equalTo("field1"));
assertThat(fields.get(1).getSchema().getTypeName(), equalTo("INTEGER"));
}
use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class EntityUtilTest method shouldBuildCorrectDecimalField.
@Test
public void shouldBuildCorrectDecimalField() {
// Given:
final SqlDecimal decimal = SqlTypes.decimal(10, 9);
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field"), decimal).build();
// When:
final List<FieldInfo> fields = EntityUtil.buildSourceSchemaEntity(schema);
// Then:
assertThat(fields, hasSize(1));
assertThat(fields.get(0).getName(), equalTo("field"));
assertThat(fields.get(0).getSchema().getTypeName(), equalTo("DECIMAL"));
assertThat(fields.get(0).getSchema().getFields(), equalTo(Optional.empty()));
assertThat(fields.get(0).getSchema().getParameters().get(SqlDecimal.SCALE), equalTo(decimal.getScale()));
assertThat(fields.get(0).getSchema().getParameters().get(SqlDecimal.PRECISION), equalTo(decimal.getPrecision()));
}
use of io.confluent.ksql.rest.entity.FieldInfo in project ksql by confluentinc.
the class EntityUtilTest method shouldBuildCorrectMapField.
@Test
public void shouldBuildCorrectMapField() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field"), SqlTypes.map(SqlTypes.BIGINT, SqlTypes.INTEGER)).build();
// When:
final List<FieldInfo> fields = EntityUtil.buildSourceSchemaEntity(schema);
// Then:
assertThat(fields, hasSize(1));
assertThat(fields.get(0).getName(), equalTo("field"));
assertThat(fields.get(0).getSchema().getTypeName(), equalTo("MAP"));
assertThat(fields.get(0).getSchema().getFields(), equalTo(Optional.empty()));
assertThat(fields.get(0).getSchema().getMemberSchema().get().getTypeName(), equalTo("INTEGER"));
}
Aggregations