liveBook · Manning

Case statement

As explained in Kafka Streams in Action, Second Edition

A CASE statement is a SQL conditional expression that evaluates conditions and returns a corresponding result.

A CASE statement evaluates conditions against a query field and returns the result for the first matching branch. In a retail event stream, it converts a purchase total into reward points. section 11.6

Assigning reward points

A ksqlDB stream-stream join selects the customer ID and purchase amount, then uses CASE: totals below 25.00 return 15 points, totals below 50.00 return 50, and all remaining totals return 75. The result is emitted as reward_points.

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains branch evaluation through a reward-tier query, without detailing broader SQL expression semantics.
Examples
Demonstrates reward-point tiers based on store purchase totals within a customer-rewards stream.
What it assumes
Assumes query fields and stream joins, while demonstrating conditional evaluation through a concrete purchase example.
What you can do after
Apply it via ksqlDB to derive categorized or tiered output fields from streaming query data.
How it connects
Connects CASE statements with ksqlDB, stream-stream joins, query projections, and conditional expressions.

Also explained in

Compare how 9 books explain case statement →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.