| 60 | } |
| 61 | |
| 62 | ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override |
| 63 | { |
| 64 | const ColumnPtr & c0 = arguments[0].column; |
| 65 | const ColumnConst * c0_const_string = typeid_cast<const ColumnConst *>(&*c0); |
| 66 | |
| 67 | if (!c0_const_string) |
| 68 | throw Exception(ErrorCodes::ILLEGAL_COLUMN, "First argument of function {} must be constant string", getName()); |
| 69 | |
| 70 | String pattern = c0_const_string->getValue<String>(); |
| 71 | |
| 72 | auto col_res = ColumnString::create(); |
| 73 | |
| 74 | VectorWithMemoryTracking<const ColumnString::Chars *> data(arguments.size() - 1); |
| 75 | VectorWithMemoryTracking<const ColumnString::Offsets *> offsets(arguments.size() - 1); |
| 76 | VectorWithMemoryTracking<size_t> fixed_string_sizes(arguments.size() - 1); |
| 77 | VectorWithMemoryTracking<std::optional<String>> constant_strings(arguments.size() - 1); |
| 78 | VectorWithMemoryTracking<ColumnString::MutablePtr> converted_col_ptrs(arguments.size() - 1); |
| 79 | |
| 80 | bool has_column_string = false; |
| 81 | bool has_column_fixed_string = false; |
| 82 | for (size_t i = 1; i < arguments.size(); ++i) |
| 83 | { |
| 84 | const ColumnPtr & column = arguments[i].column; |
| 85 | if (const ColumnString * col = checkAndGetColumn<ColumnString>(column.get())) |
| 86 | { |
| 87 | has_column_string = true; |
| 88 | data[i - 1] = &col->getChars(); |
| 89 | offsets[i - 1] = &col->getOffsets(); |
| 90 | } |
| 91 | else if (const ColumnFixedString * fixed_col = checkAndGetColumn<ColumnFixedString>(column.get())) |
| 92 | { |
| 93 | has_column_fixed_string = true; |
| 94 | data[i - 1] = &fixed_col->getChars(); |
| 95 | fixed_string_sizes[i - 1] = fixed_col->getN(); |
| 96 | } |
| 97 | else if (const ColumnConst * const_col = checkAndGetColumnConstStringOrFixedString(column.get())) |
| 98 | { |
| 99 | constant_strings[i - 1] = const_col->getValue<String>(); |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | /// A non-String/non-FixedString-type argument: use the default serialization to convert it to String. |
| 104 | /// Only strip top-level wrappers (Const, Sparse, LowCardinality) without recursing into subcolumns. |
| 105 | /// Using the recursive convertToFullIfNeeded would strip LowCardinality from inside |
| 106 | /// compound types like Variant while the type is not updated, creating a type/column mismatch. |
| 107 | auto full_column |
| 108 | = column->convertToFullColumnIfConst()->convertToFullColumnIfSparse()->convertToFullColumnIfLowCardinality(); |
| 109 | auto serialization = arguments[i].type->getDefaultSerialization(); |
| 110 | auto converted_col_str = ColumnString::create(); |
| 111 | ColumnStringHelpers::WriteHelper<ColumnString> write_helper(*converted_col_str, column->size()); |
| 112 | auto & write_buffer = write_helper.getWriteBuffer(); |
| 113 | FormatSettings format_settings; |
| 114 | for (size_t row = 0; row < column->size(); ++row) |
| 115 | { |
| 116 | serialization->serializeText(*full_column, row, write_buffer, format_settings); |
| 117 | write_helper.finishRow(); |
| 118 | } |
| 119 | write_helper.finalize(); |
nothing calls this directly
no test coverage detected