@@ -458,7 +458,7 @@ fn translate_comparison_pathelements(
458
458
/// translate a comparison target.
459
459
fn translate_comparison_target (
460
460
env : & Env ,
461
- state : & mut State ,
461
+ _state : & mut State ,
462
462
root_and_current_tables : & RootAndCurrentTables ,
463
463
column : & models:: ComparisonTarget ,
464
464
) -> Result < ( sql:: ast:: Expression , Vec < sql:: ast:: Join > ) , Error > {
@@ -485,73 +485,9 @@ fn translate_comparison_target(
485
485
joins,
486
486
) )
487
487
}
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
+ ) ) ,
555
491
}
556
492
}
557
493
0 commit comments