use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.
the class WindowingIntTest method givenTable.
private void givenTable(final String sql) {
ksqlContext.sql(String.format(sql, resultStream0));
final DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(resultStream0));
resultSchema = PhysicalSchema.from(source.getSchema(), source.getKsqlTopic().getKeyFormat().getFeatures(), source.getKsqlTopic().getValueFormat().getFeatures());
}
use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.
the class UdfIntTest method consumeOutputMessages.
private Map<GenericKey, GenericRow> consumeOutputMessages() {
final DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(resultStreamName));
final PhysicalSchema resultSchema = PhysicalSchema.from(source.getSchema(), source.getKsqlTopic().getKeyFormat().getFeatures(), source.getKsqlTopic().getValueFormat().getFeatures());
return TEST_HARNESS.verifyAvailableUniqueRows(resultStreamName, 1, KAFKA, testData.format, resultSchema);
}
use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.
the class JoinIntTest method shouldUseTimeStampFieldFromStream.
@Test
public void shouldUseTimeStampFieldFromStream() {
final String queryString = "CREATE STREAM JOINED AS " + "SELECT " + ORDER_STREAM_NAME_AVRO + ".ITEMID, ORDERID, ORDERUNITS, DESCRIPTION " + "FROM " + ORDER_STREAM_NAME_AVRO + " LEFT JOIN " + ITEM_TABLE_NAME_AVRO + " " + "ON " + ORDER_STREAM_NAME_AVRO + ".ITEMID = " + ITEM_TABLE_NAME_AVRO + ".ID " + "WHERE " + ORDER_STREAM_NAME_AVRO + ".ITEMID = 'ITEM_1';" + "" + "CREATE STREAM OUTPUT AS " + "SELECT ITEMID, ORDERID, DESCRIPTION, ROWTIME AS RT " + "FROM JOINED;";
ksqlContext.sql(queryString);
final DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of("OUTPUT"));
final Map<GenericKey, GenericRow> expectedResults = ImmutableMap.of(genericKey("ITEM_1"), genericRow("ORDER_1", "home cinema", 1L));
assertExpectedResults(expectedResults, source, orderStreamTopicAvro, KAFKA, AVRO, 120000);
}
use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.
the class JoinIntTest method shouldLeftJoinOrderAndItems.
private void shouldLeftJoinOrderAndItems(final String testStreamName, final String orderStreamTopic, final String orderStreamName, final String itemTableName, final Format valueFormat) {
final String queryString = "CREATE STREAM " + testStreamName + " AS " + "SELECT " + orderStreamName + ".ITEMID, ORDERID, ORDERUNITS, DESCRIPTION " + "FROM " + orderStreamName + " LEFT JOIN " + itemTableName + " " + "on " + orderStreamName + ".ITEMID = " + itemTableName + ".ID " + "WHERE " + orderStreamName + ".ITEMID = 'ITEM_1' ;";
ksqlContext.sql(queryString);
final DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(testStreamName));
final Map<GenericKey, GenericRow> expectedResults = ImmutableMap.of(genericKey("ITEM_1"), genericRow("ORDER_1", 10.0, "home cinema"));
assertExpectedResults(expectedResults, source, orderStreamTopic, KAFKA, valueFormat);
}
use of io.confluent.ksql.metastore.model.DataSource in project ksql by confluentinc.
the class JoinIntTest method shouldInsertLeftJoinOrderAndItems.
@Test
public void shouldInsertLeftJoinOrderAndItems() {
final String testStreamName = "OrderedWithDescription".toUpperCase();
final String commonSql = "SELECT " + ORDER_STREAM_NAME_JSON + ".ITEMID, ORDERID, ORDERUNITS, DESCRIPTION " + "FROM " + ORDER_STREAM_NAME_JSON + " LEFT JOIN " + ITEM_TABLE_NAME_JSON + " " + " on " + ORDER_STREAM_NAME_JSON + ".ITEMID = " + ITEM_TABLE_NAME_JSON + ".ID ";
final String csasQueryString = "CREATE STREAM " + testStreamName + " AS " + commonSql + "WHERE " + ORDER_STREAM_NAME_JSON + ".ITEMID = 'Hello' ;";
final String insertQueryString = "INSERT INTO " + testStreamName + " " + commonSql + "WHERE " + ORDER_STREAM_NAME_JSON + ".ITEMID = 'ITEM_1' ;";
ksqlContext.sql(csasQueryString);
ksqlContext.sql(insertQueryString);
final DataSource source = ksqlContext.getMetaStore().getSource(SourceName.of(testStreamName));
final Map<GenericKey, GenericRow> expectedResults = ImmutableMap.of(genericKey("ITEM_1"), genericRow("ORDER_1", 10.0, "home cinema"));
assertExpectedResults(expectedResults, source, orderStreamTopicJson, KAFKA, JSON);
}
Aggregations