| 167 | } |
| 168 | |
| 169 | ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override |
| 170 | { |
| 171 | /// If cache was not initialized at build time (e.g. columns were not available during analysis), |
| 172 | /// initialize it now from the actual arguments. |
| 173 | std::call_once(cache_once_flag, [&] |
| 174 | { |
| 175 | if (!cache) |
| 176 | cache = initializeTransformCache(arguments, result_type); |
| 177 | }); |
| 178 | |
| 179 | const auto * in = arguments[0].column.get(); |
| 180 | |
| 181 | if (isColumnConst(*in)) |
| 182 | return executeConst(arguments, result_type, input_rows_count); |
| 183 | |
| 184 | ColumnPtr default_non_const; |
| 185 | if (!cache->default_column && arguments.size() == 4) |
| 186 | { |
| 187 | if (arguments[1].column.get()->size() > arguments[3].column.get()->size() || arguments[2].column.get()->size() > arguments[3].column.get()->size()) |
| 188 | { |
| 189 | throw Exception( |
| 190 | ErrorCodes::BAD_ARGUMENTS, |
| 191 | "Fourth argument of function {} must be a constant or at least as big as the second and third arguments", |
| 192 | getName()); |
| 193 | } |
| 194 | default_non_const = castColumn(arguments[3], result_type); |
| 195 | /// The column might be const on some blocks (e.g. when all values are NULL), |
| 196 | /// but the code below uses insertFrom which requires matching column types. |
| 197 | /// Convert to full column to avoid ColumnNullable.insertFrom(ColumnConst) mismatch. |
| 198 | if (isColumnConst(*default_non_const)) |
| 199 | default_non_const = default_non_const->convertToFullColumnIfConst(); |
| 200 | } |
| 201 | |
| 202 | ColumnPtr in_cast = arguments[0].column; |
| 203 | if (arguments.size() == 3) |
| 204 | in_cast = castColumn(arguments[0], result_type); |
| 205 | |
| 206 | auto column_result = result_type->createColumn(); |
| 207 | if (cache->is_empty) |
| 208 | { |
| 209 | return default_non_const |
| 210 | ? default_non_const |
| 211 | : castColumn(arguments[0], result_type); |
| 212 | } |
| 213 | if (cache->table_num_to_idx) |
| 214 | { |
| 215 | if (!executeNum<ColumnVector<UInt8>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 216 | && !executeNum<ColumnVector<UInt16>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 217 | && !executeNum<ColumnVector<UInt32>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 218 | && !executeNum<ColumnVector<UInt64>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 219 | && !executeNum<ColumnVector<Int8>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 220 | && !executeNum<ColumnVector<Int16>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 221 | && !executeNum<ColumnVector<Int32>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 222 | && !executeNum<ColumnVector<Int64>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 223 | && !executeNum<ColumnVector<Float32>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 224 | && !executeNum<ColumnVector<Float64>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 225 | && !executeNum<ColumnDecimal<Decimal32>>(in, *column_result, default_non_const, *in_cast, input_rows_count) |
| 226 | && !executeNum<ColumnDecimal<Decimal64>>(in, *column_result, default_non_const, *in_cast, input_rows_count)) |
nothing calls this directly
no test coverage detected