Skip to content

Commit

Permalink
do not consider pg sources monotonic
Browse files Browse the repository at this point in the history
  • Loading branch information
guswynn committed May 10, 2022
1 parent cb8a24c commit 46528f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
25 changes: 25 additions & 0 deletions src/dataflow-types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,31 @@ pub mod sources {
}
}

/// Returns `true` if this connector yields data that is
/// append-only/monotonic. Append-monly means the source
/// never produces retractions.
// TODO(guswynn): consider enforcing this more completely at the
// parsing/typechecking level, by not using an `envelope`
// for sources like pg
pub fn append_only(&self) -> bool {
match self {
// Postgres can produce retractions (deletes)
SourceConnector::External {
connector: ExternalSourceConnector::Postgres(_),
..
} => false,
// Local sources (i.e., tables) also support retractions (deletes)
SourceConnector::Local { .. } => false,
// Other sources the `None` envelope are append-only
SourceConnector::External {
envelope: SourceEnvelope::None(_),
..
} => true,
// Other envelopes can produce retractions
_ => false,
}
}

pub fn name(&self) -> &'static str {
match self {
SourceConnector::External { connector, .. } => connector.name(),
Expand Down
6 changes: 1 addition & 5 deletions src/transform/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,7 @@ where
pub fn optimize_dataflow_monotonic(dataflow: &mut DataflowDesc) -> Result<(), TransformError> {
let mut monotonic = std::collections::HashSet::new();
for (source_id, source) in dataflow.source_imports.iter_mut() {
if let mz_dataflow_types::sources::SourceConnector::External {
envelope: mz_dataflow_types::sources::SourceEnvelope::None(_),
..
} = source.description.connector
{
if source.description.connector.append_only() {
monotonic.insert(source_id.clone());
}
}
Expand Down

0 comments on commit 46528f5

Please sign in to comment.