| 139 | } |
| 140 | |
| 141 | void InterpreterSetQuery::applyABTestProfile(ContextMutablePtr query_context) |
| 142 | { |
| 143 | if (query_context->getSettingsRef().enable_ab_test) |
| 144 | { |
| 145 | String ab_test_profile = query_context->getSettingsRef().ab_test_profile; |
| 146 | Float64 ab_test_traffic_factor = query_context->getSettingsRef().ab_test_traffic_factor; |
| 147 | if (ab_test_profile != "default" && ab_test_traffic_factor > 0 && ab_test_traffic_factor <= 1) |
| 148 | { |
| 149 | try |
| 150 | { |
| 151 | std::random_device rd; |
| 152 | std::mt19937 gen(rd()); |
| 153 | std::uniform_real_distribution<DB::Float64> distribution(0.0, 1.0); |
| 154 | Float64 res = distribution(gen); |
| 155 | if (res <= ab_test_traffic_factor) |
| 156 | query_context->setCurrentProfile(ab_test_profile); |
| 157 | } |
| 158 | catch (...) |
| 159 | { |
| 160 | tryLogWarningCurrentException(&Poco::Logger::get("applyABTestProfile"), "Apply ab test profile failed."); |
| 161 | } |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | LOG_WARNING(&Poco::Logger::get("applyABTestProfile"), "Apply ab test profile failed, ab_test_traffic_factor must be between 0 and 1, ab_test_profile != default"); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
nothing calls this directly
no test coverage detected