@@ -24,23 +24,32 @@ mlir::Type AggregatorAttr::getResultType(mlir::Type inputRel) {
2424 case AggregateFunc::ARGMIN :
2525 // NOTE: argmin(arg, val) also uses first input column as output type.
2626 return llvm::cast<RelationType>(inputRel).getColumns ()[getInputs ()[0 ]];
27+ case AggregateFunc::COUNT :
28+ return mlir::IntegerType::get (inputRel.getContext (), 64 );
29+ }
30+ }
31+
32+ static std::size_t expectedNumInputs (AggregateFunc f) {
33+ switch (f) {
34+ case AggregateFunc::SUM :
35+ case AggregateFunc::MIN :
36+ case AggregateFunc::MAX :
37+ case AggregateFunc::LOR :
38+ return 1 ;
39+ case AggregateFunc::ARGMIN :
40+ return 2 ;
41+ case AggregateFunc::COUNT :
42+ return 0 ;
2743 }
2844}
2945
3046mlir::LogicalResult
3147AggregatorAttr::verify (llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
3248 AggregateFunc func, llvm::ArrayRef<ColumnIdx> inputs) {
33- if (func == AggregateFunc::ARGMIN ) {
34- if (inputs.size () != 2 ) {
35- return emitError () << stringifyAggregateFunc (func)
36- << " expects exactly two inputs (arg, val), got "
37- << inputs.size ();
38- }
39- } else {
40- if (inputs.size () != 1 ) {
41- return emitError () << stringifyAggregateFunc (func)
42- << " expects exactly one input, got " << inputs.size ();
43- }
49+ if (inputs.size () != expectedNumInputs (func)) {
50+ return emitError () << stringifyAggregateFunc (func) << " expects exactly "
51+ << expectedNumInputs (func) << " inputs, got "
52+ << inputs.size ();
4453 }
4554
4655 return mlir::success ();
0 commit comments