Enriching streaming data
Enrichment adds values from another dataset to the rows of a stream. A stream of orders, for example, has a product number. You add the product name and the price from a product table, which changes slowly.
You enrich a stream with a join. Cloudera SQL Stream Builder (SSB) supports the join types of Flink SQL:
| Join | Use it to | More information |
|---|---|---|
| Regular join | Combine two tables for as long as both keep their rows. | Creating regular joins |
| Interval join | Combine the rows of two streams whose times are close to each other. | Creating interval joins |
| Temporal join | Add the value that was valid at the time of each row from a table that changes. | Creating temporal joins |
| Lookup join | Add the latest value from an external table, one row at a time. | Creating lookup joins |
To choose a join, ask the following:
- Do both inputs keep their rows for the whole job? Use a regular join, and limit the state of the job.
- Must the rows match in a time window? Use an interval join.
- Must the result show the value that was valid when the row happened, even for a late row? Use a temporal join with event time.
- Do you need only the newest value of an external table? Use a lookup join.
You can join tables from different connectors and different systems in one query. For example, join a Kafka stream with a table in a database or in Kudu. For more information, see Joining Kafka and Kudu tables, and for more queries, see Join examples and Hyperjoin examples.
Running the examples
The examples in this section use Datagen and Blackhole tables, so that you can run them without an external system. To run an example:
- In the Streaming SQL Console, click Projects
in the left navigation pane, and click the name of your project.
The project opens, with the Explorer panel on the left. To open the Streaming SQL Console, see Accessing Cloudera SQL Stream Builder.
- In the Explorer, open the menu of Jobs, and click New Job.
- Enter a Job Name, and click Create.
- Enter the statements of the example in the SQL editor, and click the Execute job icon.
The examples write to a Blackhole table. To see that the job processes rows, check the status of the job in the Explorer, and open the Flink Dashboard. For more information, see Using the Flink Dashboard. To see the joined rows, write them to a table of a system that you can read, such as a Kafka topic.
