| 1341 | } |
| 1342 | |
| 1343 | Expression make_count(const std::string &function_name, const std::vector<Expression> &args) { |
| 1344 | if (args.size() != 1) { |
| 1345 | std::stringstream message_ss; |
| 1346 | message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required"; |
| 1347 | throw std::runtime_error(message_ss.str()); |
| 1348 | } |
| 1349 | |
| 1350 | if (!args[0].is_multi()) { |
| 1351 | std::stringstream message_ss; |
| 1352 | message_ss << "Expression language function " << function_name << " called against singular expression."; |
| 1353 | throw std::runtime_error(message_ss.str()); |
| 1354 | } |
| 1355 | |
| 1356 | return args[0].make_aggregate([](const Parameters ¶ms, |
| 1357 | const std::vector<Expression> &sub_exprs) -> Value { |
| 1358 | uint64_t count = 0; |
| 1359 | for (const auto &sub_expr : sub_exprs) { |
| 1360 | if (sub_expr(params).asBoolean()) { |
| 1361 | count++; |
| 1362 | } |
| 1363 | } |
| 1364 | return Value(count); |
| 1365 | }); |
| 1366 | } |
| 1367 | |
| 1368 | Expression make_join(const std::string &function_name, const std::vector<Expression> &args) { |
| 1369 | if (args.size() != 2) { |
no test coverage detected