const Type* AggregateFunctionCount::resultTypeForArgumentTypes( const std::vector<const Type*> &argument_types) const { if (!canApplyToTypes(argument_types)) { return nullptr; } return &TypeFactory::GetType(kLong); }
AggregationHandle* AggregateFunctionMin::createHandle( const std::vector<const Type*> &argument_types) const { DCHECK(canApplyToTypes(argument_types)) << "Attempted to create an AggregationHandleMin for argument Type(s) " << "that MIN can not be applied to."; return new AggregationHandleMin(*argument_types.front()); }
const Type* AggregateFunctionMin::resultTypeForArgumentTypes( const std::vector<const Type*> &argument_types) const { if (!canApplyToTypes(argument_types)) { return nullptr; } return &(argument_types.front()->getNullableVersion()); }
WindowAggregationHandle* WindowAggregateFunctionCount::createHandle( const std::vector<const Type*> &argument_types, const std::vector<std::unique_ptr<const Scalar>> &partition_by_attributes, const std::vector<std::unique_ptr<const Scalar>> &order_by_attributes, const bool is_row, const std::int64_t num_preceding, const std::int64_t num_following) const { DCHECK(canApplyToTypes(argument_types)) << "Attempted to create a WindowAggregationHandleCount for argument Types " << "that COUNT can not be applied to (> 1 argument)."; // TODO(Shixuan): Add handle for Count. return nullptr; }
AggregationHandle* AggregateFunctionCount::createHandle( const std::vector<const Type*> &argument_types) const { DCHECK(canApplyToTypes(argument_types)) << "Attempted to create an AggregationHandleCount for argument Types " << "that COUNT can not be applied to (> 1 argument)."; if (argument_types.empty()) { // COUNT(*) return new AggregationHandleCount<true, false>(); } else if (argument_types.front()->isNullable()) { // COUNT(some_nullable_argument) return new AggregationHandleCount<false, true>(); } else { // COUNT(non_nullable_argument) // // TODO(chasseur): Modify query optimizer to optimize-away COUNT with a // non-nullable argument and convert it to COUNT(*). return new AggregationHandleCount<false, false>(); } }