mz_compute_types/sources.rs
1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! Types for describing dataflow sources.
11
12use mz_expr::MapFilterProject;
13use mz_repr::SqlRelationType;
14use serde::{Deserialize, Serialize};
15
16/// A description of an instantiation of a source.
17///
18/// This includes a description of the source, but additionally any
19/// context-dependent options like the ability to apply filtering and
20/// projection to the records as they emerge.
21#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
22pub struct SourceInstanceDesc<M, O = MapFilterProject> {
23 /// Arguments for this instantiation of the source.
24 pub arguments: SourceInstanceArguments<O>,
25 /// Additional metadata used by the storage client of a compute instance to read it.
26 pub storage_metadata: M,
27 /// The relation type of this source
28 pub typ: SqlRelationType,
29}
30
31/// Per-source construction arguments.
32///
33/// `O` is the form of the operators, chosen per phase:
34/// [`MirDataflowDescription`] uses [`MapFilterProject`], which the optimizer
35/// rewrites, and lowered descriptions use the form that
36/// [`LirDataflowDescription`] and [`RenderDataflowDescription`] fix.
37///
38/// [`MirDataflowDescription`]: crate::dataflows::MirDataflowDescription
39/// [`LirDataflowDescription`]: crate::dataflows::LirDataflowDescription
40/// [`RenderDataflowDescription`]: crate::dataflows::RenderDataflowDescription
41#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
42pub struct SourceInstanceArguments<O = MapFilterProject> {
43 /// Linear operators to be applied record-by-record.
44 pub operators: Option<O>,
45}