use of io.confluent.ksql.metastore.KsqlTopic in project ksql by confluentinc.
the class KsqlResource method describeTopic.
private TopicDescription describeTopic(String statementText, String name) throws KsqlException {
KsqlTopic ksqlTopic = ksqlEngine.getMetaStore().getTopic(name);
if (ksqlTopic == null) {
throw new KsqlException(String.format("Could not find Topic '%s' in the Metastore", name));
}
String schemaString = null;
TopicDescription topicDescription = new TopicDescription(statementText, name, ksqlTopic.getKafkaTopicName(), ksqlTopic.getKsqlTopicSerDe().getSerDe().toString(), schemaString);
return topicDescription;
}
use of io.confluent.ksql.metastore.KsqlTopic in project ksql by confluentinc.
the class KsqlStructuredDataOutputNodeTest method getKsqlStructuredDataOutputNode.
private KsqlStructuredDataOutputNode getKsqlStructuredDataOutputNode(boolean isWindowed) {
final Map<String, Object> props = new HashMap<>();
props.put(KsqlConfig.SINK_NUMBER_OF_PARTITIONS_PROPERTY, 4);
props.put(KsqlConfig.SINK_NUMBER_OF_REPLICAS_PROPERTY, (short) 3);
StructuredDataSourceNode tableSourceNode = new StructuredDataSourceNode(new PlanNodeId("0"), new KsqlTable("sqlExpression", "datasource", schema, schema.field("key"), schema.field("timestamp"), new KsqlTopic("input", "input", new KsqlJsonTopicSerDe()), "TableStateStore", isWindowed), schema);
return new KsqlStructuredDataOutputNode(new PlanNodeId("0"), tableSourceNode, schema, schema.field("timestamp"), schema.field("key"), new KsqlTopic("output", "output", new KsqlJsonTopicSerDe()), "output", props, Optional.empty());
}
use of io.confluent.ksql.metastore.KsqlTopic in project ksql by confluentinc.
the class StructuredDataSourceNodeTest method shouldBuildSchemaKTableWhenKTableSource.
@Test
public void shouldBuildSchemaKTableWhenKTableSource() {
StructuredDataSourceNode node = new StructuredDataSourceNode(new PlanNodeId("0"), new KsqlTable("sqlExpression", "datasource", schema, schema.field("field"), schema.field("timestamp"), new KsqlTopic("topic2", "topic2", new KsqlJsonTopicSerDe()), "statestore", false), schema);
final SchemaKStream result = build(node);
assertThat(result.getClass(), equalTo(SchemaKTable.class));
}
use of io.confluent.ksql.metastore.KsqlTopic in project ksql by confluentinc.
the class MetaStoreFixture method getNewMetaStore.
public static MetaStore getNewMetaStore() {
MetaStore metaStore = new MetaStoreImpl();
SchemaBuilder schemaBuilder1 = SchemaBuilder.struct().field("COL0", SchemaBuilder.INT64_SCHEMA).field("COL1", SchemaBuilder.STRING_SCHEMA).field("COL2", SchemaBuilder.STRING_SCHEMA).field("COL3", SchemaBuilder.FLOAT64_SCHEMA).field("COL4", SchemaBuilder.array(SchemaBuilder.FLOAT64_SCHEMA)).field("COL5", SchemaBuilder.map(SchemaBuilder.STRING_SCHEMA, SchemaBuilder.FLOAT64_SCHEMA));
KsqlTopic ksqlTopic1 = new KsqlTopic("TEST1", "test1", new KsqlJsonTopicSerDe());
KsqlStream ksqlStream = new KsqlStream("sqlexpression", "TEST1", schemaBuilder1, schemaBuilder1.field("COL0"), null, ksqlTopic1);
metaStore.putTopic(ksqlTopic1);
metaStore.putSource(ksqlStream);
SchemaBuilder schemaBuilder2 = SchemaBuilder.struct().field("COL0", SchemaBuilder.INT64_SCHEMA).field("COL1", SchemaBuilder.STRING_SCHEMA).field("COL2", SchemaBuilder.STRING_SCHEMA).field("COL3", SchemaBuilder.FLOAT64_SCHEMA).field("COL4", SchemaBuilder.BOOLEAN_SCHEMA);
KsqlTopic ksqlTopic2 = new KsqlTopic("TEST2", "test2", new KsqlJsonTopicSerDe());
KsqlTable ksqlTable = new KsqlTable("sqlexpression", "TEST2", schemaBuilder2, schemaBuilder2.field("COL0"), null, ksqlTopic2, "TEST2", false);
metaStore.putTopic(ksqlTopic2);
metaStore.putSource(ksqlTable);
SchemaBuilder schemaBuilderOrders = SchemaBuilder.struct().field("ORDERTIME", SchemaBuilder.INT64_SCHEMA).field("ORDERID", SchemaBuilder.STRING_SCHEMA).field("ITEMID", SchemaBuilder.STRING_SCHEMA).field("ORDERUNITS", SchemaBuilder.FLOAT64_SCHEMA);
KsqlTopic ksqlTopicOrders = new KsqlTopic("ORDERS_TOPIC", "orders_topic", new KsqlJsonTopicSerDe());
KsqlStream ksqlStreamOrders = new KsqlStream("sqlexpression", "ORDERS", schemaBuilderOrders, schemaBuilderOrders.field("ORDERTIME"), null, ksqlTopicOrders);
metaStore.putTopic(ksqlTopicOrders);
metaStore.putSource(ksqlStreamOrders);
return metaStore;
}
use of io.confluent.ksql.metastore.KsqlTopic in project ksql by confluentinc.
the class AvroUtilTest method shouldValidatePersistentQueryResultCorrectly.
@Test
public void shouldValidatePersistentQueryResultCorrectly() throws IOException, RestClientException {
SchemaRegistryClient schemaRegistryClient = mock(SchemaRegistryClient.class);
KsqlTopic resultTopic = new KsqlTopic("testTopic", "testTopic", new KsqlAvroTopicSerDe());
Schema resultSchema = SerDeUtil.getSchemaFromAvro(ordersAveroSchemaStr);
PersistentQueryMetadata persistentQueryMetadata = new PersistentQueryMetadata("", null, null, "", null, DataSource.DataSourceType.KSTREAM, "", mock(KafkaTopicClient.class), resultSchema, resultTopic, null);
org.apache.avro.Schema.Parser parser = new org.apache.avro.Schema.Parser();
org.apache.avro.Schema avroSchema = parser.parse(ordersAveroSchemaStr);
expect(schemaRegistryClient.testCompatibility(anyString(), EasyMock.isA(avroSchema.getClass()))).andReturn(true);
replay(schemaRegistryClient);
avroUtil.validatePersistentQueryResults(persistentQueryMetadata, schemaRegistryClient);
}
Aggregations