Skip to content

Commit 6fa57df

Browse files
committed
We'll need to implement filtering by aggregates later
1 parent 04e0f57 commit 6fa57df

File tree

2 files changed

+6
-68
lines changed

2 files changed

+6
-68
lines changed

crates/query-engine/translation/src/translation/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub enum UnsupportedCapabilities {
7474
NestedArrays,
7575
ArrayComparison,
7676
NestedScalarCollection,
77+
FilterByAggregate,
7778
}
7879

7980
impl std::fmt::Display for UnsupportedCapabilities {
@@ -91,6 +92,7 @@ impl std::fmt::Display for UnsupportedCapabilities {
9192
UnsupportedCapabilities::NestedScalarCollection => {
9293
write!(f, "Nested Scalar Collection")
9394
}
95+
UnsupportedCapabilities::FilterByAggregate => write!(f, "Filter By Aggregate"),
9496
}
9597
}
9698
}

crates/query-engine/translation/src/translation/query/filtering.rs

Lines changed: 4 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ fn translate_comparison_pathelements(
458458
/// translate a comparison target.
459459
fn translate_comparison_target(
460460
env: &Env,
461-
state: &mut State,
461+
_state: &mut State,
462462
root_and_current_tables: &RootAndCurrentTables,
463463
column: &models::ComparisonTarget,
464464
) -> Result<(sql::ast::Expression, Vec<sql::ast::Join>), Error> {
@@ -485,73 +485,9 @@ fn translate_comparison_target(
485485
joins,
486486
))
487487
}
488-
ndc_models::ComparisonTarget::Aggregate { path, aggregate } => {
489-
let (table_ref, joins) =
490-
translate_comparison_pathelements(env, state, root_and_current_tables, path)?;
491-
492-
match aggregate {
493-
ndc_models::Aggregate::ColumnCount {
494-
column,
495-
arguments: _,
496-
field_path,
497-
distinct,
498-
} => {
499-
let collection_info = env.lookup_fields_info(&table_ref.source)?;
500-
let ColumnInfo { name, .. } = collection_info.lookup_column(column)?;
501-
502-
let column_reference = wrap_in_field_path(
503-
&field_path.into(),
504-
sql::ast::Expression::ColumnReference(
505-
sql::ast::ColumnReference::TableColumn {
506-
table: table_ref.reference.clone(),
507-
name,
508-
},
509-
),
510-
);
511-
512-
Ok((
513-
sql::ast::Expression::Count(if *distinct {
514-
sql::ast::CountType::Distinct(Box::new(column_reference))
515-
} else {
516-
sql::ast::CountType::Simple(Box::new(column_reference))
517-
}),
518-
joins,
519-
))
520-
}
521-
ndc_models::Aggregate::SingleColumn {
522-
column,
523-
arguments: _,
524-
field_path,
525-
function,
526-
} => {
527-
let collection_info = env.lookup_fields_info(&table_ref.source)?;
528-
let ColumnInfo { name, .. } = collection_info.lookup_column(column)?;
529-
530-
let column_reference = wrap_in_field_path(
531-
&field_path.into(),
532-
sql::ast::Expression::ColumnReference(
533-
sql::ast::ColumnReference::TableColumn {
534-
table: table_ref.reference.clone(),
535-
name,
536-
},
537-
),
538-
);
539-
540-
Ok((
541-
sql::ast::Expression::FunctionCall {
542-
function: sql::ast::Function::Unknown(function.to_string()),
543-
args: vec![column_reference],
544-
},
545-
joins,
546-
))
547-
}
548-
// todo: is this sound? this count is not targeted, but maybe that is fine?
549-
ndc_models::Aggregate::StarCount {} => Ok((
550-
sql::ast::Expression::Count(sql::ast::CountType::Star),
551-
joins,
552-
)),
553-
}
554-
}
488+
ndc_models::ComparisonTarget::Aggregate { .. } => Err(Error::CapabilityNotSupported(
489+
UnsupportedCapabilities::FilterByAggregate,
490+
)),
555491
}
556492
}
557493

0 commit comments

Comments
 (0)