Skip to main content

Module channel_derivation

Module channel_derivation 

Source
Expand description

Channel type derivation from query plan analysis.

This module analyzes query plans to automatically determine whether sources need SPSC (single consumer) or broadcast (multiple consumer) channels.

§Key Principle

Users never specify broadcast mode. The planner analyzes MVs and sources to derive the correct channel type automatically:

  • If a source is consumed by exactly 1 MV → SPSC (optimal)
  • If a source is consumed by 2+ MVs → Broadcast

§Example

CREATE SOURCE trades (...);

CREATE MATERIALIZED VIEW vwap AS
  SELECT symbol, SUM(price * volume) / SUM(volume) AS vwap
  FROM trades
  GROUP BY symbol, TUMBLE(ts, INTERVAL '1' MINUTE);

CREATE MATERIALIZED VIEW max_price AS
  SELECT symbol, MAX(price)
  FROM trades
  GROUP BY symbol, TUMBLE(ts, INTERVAL '1' MINUTE);

In this example, trades source has 2 consumers (vwap and max_price), so the planner derives Broadcast { consumer_count: 2 } for trades.

Structs§

ChannelDerivationResult
Channel derivation result with additional metadata.
MvDefinition
Materialized view definition for channel derivation.
SourceDefinition
Source definition for channel derivation.

Enums§

DerivedChannelType
Channel type derived from query analysis.

Functions§

analyze_mv_sources
Analyzes a single MV to extract its source references.
derive_channel_types
Analyzes query plan to determine channel types per source.
derive_channel_types_detailed
Derives channel types with additional analysis metadata.