Expand description
Module dedicated to the maintenance and query of materialized views
Unlike the telemetry data lake where it’s fast & cheap to write but costly to read, the lakehouse partitions are costly to write but allow for cheap & fast queries using datafusion.
Views based on a low frequency of events (< 1k events per second per process) are kept updated regularly. Views based on a high frequency of events (up to 100k events per second per process) are metrialized on demand.
Modules§
- answer
- Record batches + schema
- async_
events_ block_ processor - Implementation of
BlockProcessorfor async events - async_
events_ view - Materializable view of async span events accessible through datafusion
- async_
parquet_ writer - Write parquet in object store
- audience_
guard - The call-level guard: per-id audience
resolution (
AudienceIndex) and the fail-closed guard (AudienceGuard) for the span/metadata UDTFs andget_payloadUDFOwnershipRewrite(the row-level filter) structurally cannot reach, plus a scan-time guard onview_instance(...). For the six view sets carrying a physicalaudiencecolumn, the row-level filter can and does reach aview_instancescan too, row-filtering it the same as the named-table form – thereview_instancejoined the call-level guard to close a cost/availability residual (stopping JIT materialization for a foreign-audience instance), not because the row-level filter can’t filter it. For the other five view sets, reachable only through a guardedview_instance(...), the row-level filter injects no predicate at all, so this guard is their sole enforcement. The call-level guard – arg-addressed guards for five entry points: the span/metadata UDTFs and theget_payloadUDF thatcrate::lakehouse::ownership_rewrite::OwnershipRewrite(the row-level filter) structurally cannot reach (they bake their target id into a provider at plan time, return schemas with noprocess_idcolumn to filter on, and some build their own inner session underReadScope::All), plusview_instance(...). For the six view sets carrying a physicalaudiencecolumn, the row-level filter can and does reach aview_instancescan too – it row-filters it the same as the named-table form – so this guard’s job there is only to stop a caller from triggering JIT materialization (real compute and object-storage writes) for an instance outside their audiences before the row-level filter ever gets to run, a cost/availability concern rather than a confidentiality one. For the other five view sets (net_spans,otel_spans,images,async_events,thread_spans– reachable only through a guardedview_instance(...), never as a named table), the row-level filter injects no per-row predicate at all once this guard is in place – seecrate::lakehouse::materialized_view::MaterializedView::instance_is_audience_guardedandOwnershipRewrite’s module doc for the other side of that coupling – so this guard is their sole confidentiality enforcement, not a redundant belt-and-braces check. - batch_
update - Materialize views on a schedule based on the time data was received from the ingestion service
- block_
object_ decoder - Format → decoder registry for
parse_block, mirroringBlockProcessorMapFormat → decoder registry forparse_block: turns a block payload of any registeredstreams.formatinto generic(type_name, jsonb)objects, one per row, mirroring the existingBlockProcessorMappattern (block_partition_spec.rs). - block_
partition_ spec - Specification for a view partition backed by a set of telemetry blocks which can be processed out of order
- blocks_
view - Replicated view of the
blockstable of the postgresql metadata database. - catalog
- Catalog utilities for discovering and managing view schemas Catalog utilities for discovering and managing view schemas.
- dataframe_
time_ bounds - deny_
queries_ table_ function - Admin UDTF that validates and inserts a query-deny-list rule
deny_queries(match_expr, reason)– admin UDTF that validates and inserts a new query-deny- list rule.call_with_argsruns every validation synchronously and fail-loud withplan_err!: expression compilation (compile_match_expr, against the bareSessionContextQueryDenyListholds for exactly this, not the caller’s own session – rule compilation must produce the same result on every replica regardless of whose session triggered it), the empty-reasoncheck, the caller-identity check (CallerContext::identitymust beSome), and the rule-count check against the current snapshot. Only the DB write and the local snapshot refresh happen in the async body, behindLogStreamTableProvider/TaskLogExecPlan–QueryDenyList::inserttakes the already-compiled expression and cannot itself fail on a bad expression. - export_
log_ view - Export mechanism that doubles as audit trail
- get_
payload_ function - Fetch payload from the object store using SQL
- image_
block_ processor - Implementation of
BlockProcessorfor images - images_
view - Materializable view of images accessible through datafusion
- jit_
partitions - Management of process-specific partitions built on demand
Just-in-time (JIT) partition generation groups a view’s source blocks (queried from
blocks_viewinORDER BY insert_time, block_idorder) intoSourceDataBlocksInMemorypartitions no larger thanJitPartitionConfig::max_nb_objects. - lakehouse_
context - Bundles runtime resources for lakehouse query execution
- list_
audience_ grants_ table_ function - Caller-scoped UDTF listing rows of the
audience_grantstablelist_audience_grants()– caller-scoped UDTF listing rows of theaudience_grantstable. Modeled onlist_query_denials_table_function.rs’s shape (aTableFunctionImplwhose synccall_with_argsreturns a lazyTableProvider, an asyncscanthat runs the DB query and builds arrays), but registered outside the admin gate inregister_lakehouse_functions, next tolist_view_sets()– every authenticated caller (and, peris_admin(metadata)’s documented--disable-authconvention, every caller when auth is disabled) can call it, scoped bycrate::lakehouse::list_audience_grants_table_function::GrantVisibility. - list_
partitions_ table_ function - Read access to the list of lakehouse partitions
- list_
query_ denials_ table_ function - Admin UDTF listing every query-deny-list rule currently in force
list_query_denials()– admin UDTF listing every query-deny-list rule currently in force. Registered inside the same admin-gated block aslist_partitions()’s mutating siblings. - list_
view_ set_ definitions_ table_ function - Admin UDTF listing every row of
lakehouse_view_set_definitions, straight from Postgreslist_view_set_definitions()– admin UDTF listing every row oflakehouse_view_set_definitions, straight from Postgres rather than fromViewRegistry::current()– so an admin can see a definition that exists on disk but failed to load (present here, absent fromlist_view_sets()). Registered inside the same admin-gated block aslist_query_denials()’s siblings. - list_
view_ sets_ table_ function - Read access to view sets with their schema information
- log_
block_ processor - Implementation of
BlockProcessorfor log entries - log_
stats_ view - SQL-based view for log statistics aggregated by process, minute, level, and target
- log_
view - Materializable view of log entries accessible through datafusion
- materialize_
partitions_ table_ function - Exposes materialize_partitions as a table function
- materialized_
view - TableProvider implementation for the lakehouse
- merge
- Merge consecutive parquet partitions into a single file
- metadata_
cache - Global LRU cache for partition metadata
- metadata_
partition_ spec - Specification for a view partition backed by a table in the postgresql metadata database.
- metrics_
block_ processor - Implementation of
BlockProcessorfor measures - metrics_
view - Materializable view of measures accessible through datafusion
- migration
- Maintenance of the postgresql tables and indices use to track the parquet files used to implement the views
- net_
spans_ view - Jit view of pre-paired network bandwidth spans (Connection / Object / Property / RPC)
- otel
- OTLP reader path: attribute helpers, block processors, and the otel_spans view.
- ownership_
rewrite - The row-level filter: injects an audience predicate into every
MaterializedViewscan based on the caller’sReadScope.OwnershipRewrite– the row-level filter. - parse_
block_ table_ function - Table function to parse all transit objects in a block and return them as JSONB
- partition
- Write & delete sections of views
- partition_
cache - In-memory copy of a subnet of the list of the partitions in the db
- partition_
metadata - Reads and parses partition Parquet footers directly from object storage
- partition_
source_ data - Describes the event blocks backing a partition
- partitioned_
execution_ plan - ExecutionPlan based on a set of parquet files
- partitioned_
table_ provider - TableProvider based on a set of parquet files
- perfetto_
trace_ execution_ plan - ExecutionPlan for generating Perfetto trace chunks
- perfetto_
trace_ table_ function - Table function for generating Perfetto trace chunks
- process_
spans_ table_ function - Table function returning thread and/or async spans from all CPU streams of a process
- process_
streams - Shared utilities for discovering CPU streams of a process
- processes_
view - Replicated view of the
processestable of the postgresql metadata database. - query
- property_get function support from SQL Datafusion integration
- query_
deny_ list - Admin-managed query deny list: fingerprinting, the match
context, and the Postgres-backed, TTL-refreshed cache
execute_querychecks every query against. Admin-managed query deny list: a small set of admin-authored rules, stored in Postgres, cached in everyflight-sql-srvreplica, and evaluated at the front ofexecute_query– before the session context is built and before planning – so a matching query is rejected for a few microseconds of work instead of a memory-pool reservation and a wave of object-store reads. - read_
scope - Authorization seam input:
ReadScopeand theCallerContextbundle threaded intomake_session_context. Consumed by the row-level filter (ownership_rewrite::OwnershipRewrite) and the call-level guard (audience_guard::AudienceGuard). The analytics-side half of the authorization seam. - reader_
factory - Wrapper around ParquetObjectreader to provide ParquetMetaData, reading footers from the ObjectStore through a cache-backed reader
- regenerate_
partitions_ table_ function - Exposes regenerate_partitions as a table function that force-regenerates partitions directly from source data
- remove_
query_ denial_ udf - Admin scalar UDF that removes a single query-deny-list rule by id
remove_query_denial(rule_id)– admin scalar UDF that deletes a query-deny-list rule. The audit log is the durable record of what was denied and what it rejected, so the row itself does not need to survive its removal (hard delete, noremoved_at/removed_bytrail). - retire_
partition_ by_ file_ udf - Scalar UDF to retire a single partition by file path
- retire_
partition_ by_ metadata_ udf - Scalar UDF to retire a single partition by metadata
- retire_
partitions_ table_ function - Exposes retire_partitions as a table function
- runtime
- Runtime resources
- scoped_
memory_ pool - Per-query
MemoryPoolwrapper that adds accounting on top of a shared pool Per-query [datafusion::execution::memory_pool::MemoryPool] wrapper that adds accounting on top of a shared pool. - session_
configurator - SessionConfigurator trait for custom session context configuration
- sql_
batch_ view - Sql-defined view updated in batch
- sql_
partition_ spec - Specification for a view partition backed by a SQL query on the lakehouse.
- static_
tables_ configurator - Auto-discovery configurator for static JSON/CSV tables
- streams_
view - Replicated view of the
streamstable of the postgresql metadata database. - table_
scan_ rewrite - Rewrite table scans to take the query range into account
- temp
- Tracking of expired partitions
- thread_
spans_ view - Jit view of the call tree built from the thread events of a single stream
- view
- Basic interface for a set of rows queryable and materializable
- view_
definition - The normalized shape of a DDL-defined (or seeded) materialized view, and the validation shared
by the DDL executor and the registry loader.
The normalized shape of a DDL-defined (or seeded) materialized view – the three queries plus
every option – and the one
validate_view_definitionfunction shared by the DDL executor (rust/public/src/servers/view_ddl.rs) and the registry loader (view_registry.rs), so a definition the loader would skip can never be accepted atCREATEtime in the first place. - view_
definition_ store - Postgres-backed persistence for DDL-defined view definitions
(
lakehouse_view_set_definitions). Postgres-backed persistence forlakehouse_view_set_definitions. - view_
factory default_view_factorymakes the defaultViewFactory, giving users access to view instances, grouped in sets.- view_
instance_ table_ function - Table function to query process-specific views
- view_
registry - Shared
Arc<ViewFactory>rebuilt from Postgres-backed view definitions on a timer, givingtelemetry-maintenance-srvandflight-sql-srva common, reloadable view of DDL-defined view sets without a restart.ViewRegistry: a sharedArc<ViewFactory>(the code-driven base plus every DDL-defined global view) rebuilt fromlakehouse_view_set_definitionson a timer, sotelemetry-maintenance-srvandflight-sql-srvboth start reading/materializing a new or changed view set without a restart. Shaped afterQueryDenyList: a Postgres-backed store, an immutable compiled snapshot behind a lock, arefresh/reloadthat logs and meters its own failures, andspawn_refresh_task. - write_
partition - Add or remove view partitions