958 std::shared_ptr<Analyzer::Expr> arg_expr;
960 if (boost::iequals(*
name_,
"count")) {
964 arg_expr =
arg_->analyze(catalog, query, allow_tlist_ref);
967 throw std::runtime_error(
968 "Strings must be dictionary-encoded in COUNT(DISTINCT).");
971 throw std::runtime_error(
"Only COUNT(DISTINCT) is supported on arrays.");
977 throw std::runtime_error(
"Cannot compute " + *
name_ +
" with argument '*'.");
979 if (boost::iequals(*
name_,
"min")) {
981 arg_expr =
arg_->analyze(catalog, query, allow_tlist_ref);
982 arg_expr = arg_expr->decompress();
983 result_type = arg_expr->get_type_info();
984 }
else if (boost::iequals(*
name_,
"max")) {
986 arg_expr =
arg_->analyze(catalog, query, allow_tlist_ref);
987 arg_expr = arg_expr->decompress();
988 result_type = arg_expr->get_type_info();
989 }
else if (boost::iequals(*
name_,
"avg")) {
991 arg_expr =
arg_->analyze(catalog, query, allow_tlist_ref);
992 if (!arg_expr->get_type_info().is_number()) {
993 throw std::runtime_error(
"Cannot compute AVG on non-number-type arguments.");
995 arg_expr = arg_expr->decompress();
997 }
else if (boost::iequals(*
name_,
"sum")) {
999 arg_expr =
arg_->analyze(catalog, query, allow_tlist_ref);
1000 if (!arg_expr->get_type_info().is_number()) {
1001 throw std::runtime_error(
"Cannot compute SUM on non-number-type arguments.");
1003 arg_expr = arg_expr->decompress();
1005 : arg_expr->get_type_info();
1006 }
else if (boost::iequals(*
name_,
"unnest")) {
1007 arg_expr =
arg_->analyze(catalog, query, allow_tlist_ref);
1008 const SQLTypeInfo& arg_ti = arg_expr->get_type_info();
1010 throw std::runtime_error(
arg_->to_string() +
" is not of array type.");
1014 throw std::runtime_error(
"invalid function name: " + *
name_);
1016 if (arg_expr->get_type_info().is_string() ||
1017 arg_expr->get_type_info().get_type() ==
kARRAY) {
1018 throw std::runtime_error(
1019 "Only COUNT(DISTINCT ) aggregate is supported on strings and arrays.");
1024 return makeExpr<Analyzer::AggExpr>(
1025 result_type, agg_type, arg_expr,
is_distinct,
nullptr);
HOST DEVICE SQLTypes get_type() const
std::unique_ptr< std::string > name_
std::unique_ptr< Expr > arg_
HOST DEVICE EncodingType get_compression() const
SQLTypeInfo get_elem_type() const
bool is_distinct(const size_t input_idx, const RelAlgNode *node)