Using ksqlDB you can build stateful aggregations of state on events in Apache Kafka topics. These are persisted as Kafka topics and held in a state store within ksqlDB that you can query directly or from an external application using the Java client or REST API.
ksqlDB uses SQL to describe the stream processing that you want to do. For example:
CREATE TABLE ORDERS_BY_MAKE AS
SELECT MAKE,
COUNT(*) AS ORDER_COUNT,
SUM(TOTAL_ORDER_VALUE) AS TOTAL_ORDER_VALUE
FROM ORDERS
GROUP BY MAKE;
-----
💾 Run ksqlDB yourself: ksqldb.io?.devx_ch.rmoff_youtube__-j7aKE0kl0&
☁️ Use ksqlDB as a managed service: www.confluent.io/confluent-cl...
👾 Demo code: github.com/confluentinc/demo-...
🤔 Questions? Join the Confluent Community at confluent.io/community/ask-th...
ksqlDB REST API: docs.ksqldb.io/en/latest/deve...
ksqlDB Java client: docs.ksqldb.io/en/latest/deve...
-----
⏱ Time codes
00:00:00 Introduction
00:00:48 Querying the source stream
00:01:28 COUNT(*)… GROUP BY in ksqlDB
00:02:02 Continuous aggregation
00:02:11 As new data arrives, the aggregate is updated
00:02:36 Persisting an aggregate in ksqlDB as a TABLE
00:03:04 Why are aggregates TABLEs? Because they're a value for a given key (the GROUP BY clause)
00:03:20 CREATE TABLE … AS SELECT
00:03:42 Listing tables in ksqlDB
00:03:48 Examining the schema of a table
00:03:56 Querying a table (push query)
00:04:35 ksqlDB creates internal state store to hold aggregates
00:04:55 Querying the state store directly in ksqlDB (pull query)
00:05:11 Quyerying the materialised cache in ksqlDB
00:05:45 Pull vs Push queries
00:06:34 Windowed aggregations in ksqlDB
00:07:29 Creating a tumbling window in ksqlDB
00:07:39 Keys in windowed aggregations
00:07:49 Windows start from the Unix epoch
00:08:09 Casting DOUBLE to DECIMAL in ksqlDB
00:08:20 Using a pull query to view the state of a tumbling windowed aggregate in ksqlDB
00:08:31 WINDOWSTART and WINDOWEND system columns
00:09:48 Handling late-arriving data in ksqlDB
00:10:10 Querying the ksqlDB materialised state store from an application
00:10:48 Building aggregates to alert on a threshold with the HAVING clause
00:12:03 Writing threshold alerts to a new Kafka topic
00:12:55 Recap
3 авг 2024