pub fn output_type(&self, input_type: ColumnType) -> ColumnType {
        let scalar_type = match self {
            AggregateFunc::Count => ScalarType::Int64,
            AggregateFunc::Any => ScalarType::Bool,
            AggregateFunc::All => ScalarType::Bool,
            AggregateFunc::JsonbAgg { .. } => ScalarType::Jsonb,
            AggregateFunc::JsonbObjectAgg { .. } => ScalarType::Jsonb,
            AggregateFunc::SumInt16 => ScalarType::Int64,
            AggregateFunc::SumInt32 => ScalarType::Int64,
            AggregateFunc::SumInt64 => ScalarType::Numeric { scale: Some(0) },
            AggregateFunc::ArrayConcat { .. } | AggregateFunc::ListConcat { .. } => {
                match input_type.scalar_type {
                    // The input is wrapped in a Record if there's an ORDER BY, so extract it out.
                    ScalarType::Record { fields, .. } => fields[0].1.scalar_type.clone(),
                    _ => unreachable!(),
                }
            }
            AggregateFunc::StringAgg { .. } => ScalarType::String,
            AggregateFunc::RowNumber { .. } => match input_type.scalar_type {
                ScalarType::Record { fields, .. } => ScalarType::List {
                    element_type: Box::new(ScalarType::Record {
                        fields: vec![
                            (
                                ColumnName::from("?row_number?"),
                                ScalarType::Int64.nullable(false),
                            ),
                            (ColumnName::from("?record?"), {
                                let inner = match &fields[0].1.scalar_type {
                                    ScalarType::List { element_type, .. } => element_type.clone(),
                                    _ => unreachable!(),
                                };
                                inner.nullable(false)
                            }),
                        ],
                        custom_oid: None,
                        custom_name: None,
                    }),
                    custom_oid: None,
                },
                _ => unreachable!(),
            },
            // Note AggregateFunc::MaxString, MinString rely on returning input
            // type as output type to support the proper return type for
            // character input.
            _ => input_type.scalar_type,
        };
        // Count never produces null, and other aggregations only produce
        // null in the presence of null inputs.
        let nullable = match self {
            AggregateFunc::Count => false,
            _ => input_type.nullable,
        };
        scalar_type.nullable(nullable)
    }
/// The output column type for the result of an aggregation.
///
/// The output column type also contains nullability information, which
/// is (without further information) true for aggregations that are not
/// counts.
The output column type for the result of an aggregation.
The output column type also contains nullability information, which
is (without further information) true for aggregations that are not
counts.
The output column type for the result of an aggregation . The output column type also contains nullability information which is ( without further information ) true for aggregations that are not counts .
pub fn output_type(&self, input_type: ColumnType) -> ColumnType {
        let scalar_type = match self {
            AggregateFunc::Count => ScalarType::Int64,
            AggregateFunc::Any => ScalarType::Bool,
            AggregateFunc::All => ScalarType::Bool,
            AggregateFunc::JsonbAgg { .. } => ScalarType::Jsonb,
            AggregateFunc::JsonbObjectAgg { .. } => ScalarType::Jsonb,
            AggregateFunc::SumInt16 => ScalarType::Int64,
            AggregateFunc::SumInt32 => ScalarType::Int64,
            AggregateFunc::SumInt64 => ScalarType::Numeric { scale: Some(0) },
            AggregateFunc::ArrayConcat { .. } | AggregateFunc::ListConcat { .. } => {
                match input_type.scalar_type {
                    // The input is wrapped in a Record if there's an ORDER BY, so extract it out.
                    ScalarType::Record { fields, .. } => fields[0].1.scalar_type.clone(),
                    _ => unreachable!(),
                }
            }
            AggregateFunc::StringAgg { .. } => ScalarType::String,
            AggregateFunc::RowNumber { .. } => match input_type.scalar_type {
                ScalarType::Record { fields, .. } => ScalarType::List {
                    element_type: Box::new(ScalarType::Record {
                        fields: vec![
                            (
                                ColumnName::from("?row_number?"),
                                ScalarType::Int64.nullable(false),
                            ),
                            (ColumnName::from("?record?"), {
                                let inner = match &fields[0].1.scalar_type {
                                    ScalarType::List { element_type, .. } => element_type.clone(),
                                    _ => unreachable!(),
                                };
                                inner.nullable(false)
                            }),
                        ],
                        custom_oid: None,
                        custom_name: None,
                    }),
                    custom_oid: None,
                },
                _ => unreachable!(),
            },
            // Note AggregateFunc::MaxString, MinString rely on returning input
            // type as output type to support the proper return type for
            // character input.
            _ => input_type.scalar_type,
        };
        // Count never produces null, and other aggregations only produce
        // null in the presence of null inputs.
        let nullable = match self {
            AggregateFunc::Count => false,
            _ => input_type.nullable,
        };
        scalar_type.nullable(nullable)
    }
pub fn output_type ( & self , input_type : ColumnType ) -> ColumnType { let scalar_type = match self { AggregateFunc :: Count => ScalarType :: Int64 , AggregateFunc :: Any => ScalarType :: Bool , AggregateFunc :: All => ScalarType :: Bool , AggregateFunc :: JsonbAgg { .. } => ScalarType :: Jsonb , AggregateFunc :: JsonbObjectAgg { .. } => ScalarType :: Jsonb , AggregateFunc :: SumInt16 => ScalarType :: Int64 , AggregateFunc :: SumInt32 => ScalarType :: Int64 , AggregateFunc :: SumInt64 => ScalarType :: Numeric { scale : Some ( 0 ) } , AggregateFunc :: ArrayConcat { .. } | AggregateFunc :: ListConcat { .. } => { match input_type . scalar_type { // The input is wrapped in a Record if there's an ORDER BY, so extract it out. ScalarType :: Record { fields , .. } => fields [ 0 ] . 1 . scalar_type . clone ( ) , _ => unreachable ! ( ) , } } AggregateFunc :: StringAgg { .. } => ScalarType :: String , AggregateFunc :: RowNumber { .. } => match input_type . scalar_type { ScalarType :: Record { fields , .. } => ScalarType :: List { element_type : Box :: new ( ScalarType :: Record { fields : vec ! [ ( ColumnName from ( " " ) ScalarType Int64 nullable ( false ) ) ( ColumnName from ( " " ) { let inner match fields [ 0 ] 1 scalar_type { ScalarType List { element_type } element_type clone ( ) unreachable ( ) } inner nullable ( false ) } ) ] , custom_oid : None , custom_name : None , } ) , custom_oid : None , } , _ => unreachable ! ( ) , } , // Note AggregateFunc::MaxString, MinString rely on returning input // type as output type to support the proper return type for // character input. _ => input_type . scalar_type , } ; // Count never produces null, and other aggregations only produce // null in the presence of null inputs. let nullable = match self { AggregateFunc :: Count => false , _ => input_type . nullable , } ; scalar_type . nullable ( nullable ) }
The output column type for the result of an aggregation.
The output column type for the result of an aggregation .
&self
input_type
ColumnType
&self
input_type
ColumnType