| 1781 | } |
| 1782 | |
| 1783 | std::unique_ptr<SQLType> StatementGenerator::randomAggregateType(RandomGenerator & rg, const bool simple, BottomTypeName * tp) |
| 1784 | { |
| 1785 | uint32_t col_counter2 = 0; |
| 1786 | std::vector<AggregateParam> params; |
| 1787 | std::vector<std::unique_ptr<SQLType>> subtypes; |
| 1788 | AggregateFunction * af = tp ? tp->mutable_aggr() : nullptr; |
| 1789 | const CHAggregate & agg = rg.pickRandomly(simple ? simple_det_aggrs : det_aggrs); |
| 1790 | std::string aggr = agg.fname; |
| 1791 | uint32_t nargs = agg.min_args == agg.max_args ? agg.min_args : rg.randomInt<uint32_t>(agg.min_args, agg.max_args); |
| 1792 | |
| 1793 | if (agg.min_params > 0) |
| 1794 | { |
| 1795 | const uint32_t nparams = agg.min_params == agg.max_params |
| 1796 | ? agg.min_params |
| 1797 | : rg.randomInt<uint32_t>(agg.min_params, std::min(agg.max_params, UINT32_C(5))); |
| 1798 | for (uint32_t i = 0; i < nparams; i++) |
| 1799 | { |
| 1800 | AggregateParam p; |
| 1801 | if (rg.nextBool()) |
| 1802 | p.set_float_param(rg.randomInt<uint32_t>(0, 100) / 100.0); |
| 1803 | else |
| 1804 | p.set_int_param(rg.randomInt<uint64_t>(0, 100)); |
| 1805 | params.push_back(p); |
| 1806 | if (af) |
| 1807 | *af->add_params() = p; |
| 1808 | } |
| 1809 | } |
| 1810 | if (nargs == 0 && (simple || this->depth >= this->fc.max_depth)) |
| 1811 | { |
| 1812 | aggr = "any"; |
| 1813 | nargs = 1; |
| 1814 | params.clear(); |
| 1815 | if (af) |
| 1816 | af->clear_params(); |
| 1817 | } |
| 1818 | for (uint32_t i = 0; i < nargs; i++) |
| 1819 | { |
| 1820 | this->depth++; |
| 1821 | subtypes.emplace_back( |
| 1822 | this->randomNextType(rg, this->next_type_mask & ~(allow_nested), col_counter2, tp ? af->add_types() : nullptr)); |
| 1823 | this->depth--; |
| 1824 | } |
| 1825 | if (tp) |
| 1826 | { |
| 1827 | af->set_simple(simple); |
| 1828 | af->set_aggr(aggr); |
| 1829 | } |
| 1830 | return std::make_unique<AggregateFunctionType>(simple, std::move(aggr), std::move(params), std::move(subtypes)); |
| 1831 | } |
| 1832 | |
| 1833 | std::unique_ptr<SQLType> |
| 1834 | StatementGenerator::bottomType(RandomGenerator & rg, const uint64_t allowed_types, const bool low_card, BottomTypeName * tp) |
nothing calls this directly
no test coverage detected