|
23 | 23 | #include <DataTypes/DataTypeNothing.h> |
24 | 24 | #include <DataTypes/DataTypeUUID.h> |
25 | 25 | #include <DataTypes/DataTypeInterval.h> |
| 26 | +#include <DataTypes/DataTypeAggregateFunction.h> |
26 | 27 | #include <Formats/FormatSettings.h> |
27 | 28 | #include <Columns/ColumnString.h> |
28 | 29 | #include <Columns/ColumnFixedString.h> |
@@ -636,7 +637,7 @@ struct ConvertImplGenericFromString |
636 | 637 | { |
637 | 638 | ReadBufferFromMemory read_buffer(&chars[current_offset], offsets[i] - current_offset - 1); |
638 | 639 |
|
639 | | - data_type_to.deserializeAsTextEscaped(column_to, read_buffer, format_settings); |
| 640 | + data_type_to.deserializeAsWholeText(column_to, read_buffer, format_settings); |
640 | 641 |
|
641 | 642 | if (!read_buffer.eof()) |
642 | 643 | throwExceptionForIncompletelyParsedValue(read_buffer, block, result); |
@@ -1669,6 +1670,21 @@ class FunctionCast final : public IFunctionBase |
1669 | 1670 | }; |
1670 | 1671 | } |
1671 | 1672 |
|
| 1673 | + WrapperType createAggregateFunctionWrapper(const DataTypePtr & from_type_untyped, const DataTypeAggregateFunction * to_type) const |
| 1674 | + { |
| 1675 | + /// Conversion from String through parsing. |
| 1676 | + if (checkAndGetDataType<DataTypeString>(from_type_untyped.get())) |
| 1677 | + { |
| 1678 | + return [] (Block & block, const ColumnNumbers & arguments, const size_t result, size_t /*input_rows_count*/) |
| 1679 | + { |
| 1680 | + ConvertImplGenericFromString::execute(block, arguments, result); |
| 1681 | + }; |
| 1682 | + } |
| 1683 | + else |
| 1684 | + throw Exception{"Conversion from " + from_type_untyped->getName() + " to " + to_type->getName() + |
| 1685 | + " is not supported", ErrorCodes::CANNOT_CONVERT_TYPE}; |
| 1686 | + } |
| 1687 | + |
1672 | 1688 | WrapperType createArrayWrapper(const DataTypePtr & from_type_untyped, const DataTypeArray * to_type) const |
1673 | 1689 | { |
1674 | 1690 | /// Conversion from String through parsing. |
@@ -2145,13 +2161,12 @@ class FunctionCast final : public IFunctionBase |
2145 | 2161 | case TypeIndex::Tuple: |
2146 | 2162 | return createTupleWrapper(from_type, checkAndGetDataType<DataTypeTuple>(to_type.get())); |
2147 | 2163 |
|
| 2164 | + case TypeIndex::AggregateFunction: |
| 2165 | + return createAggregateFunctionWrapper(from_type, checkAndGetDataType<DataTypeAggregateFunction>(to_type.get())); |
2148 | 2166 | default: |
2149 | 2167 | break; |
2150 | 2168 | } |
2151 | 2169 |
|
2152 | | - /// It's possible to use ConvertImplGenericFromString to convert from String to AggregateFunction, |
2153 | | - /// but it is disabled because deserializing aggregate functions state might be unsafe. |
2154 | | - |
2155 | 2170 | throw Exception{"Conversion from " + from_type->getName() + " to " + to_type->getName() + " is not supported", |
2156 | 2171 | ErrorCodes::CANNOT_CONVERT_TYPE}; |
2157 | 2172 | } |
|
0 commit comments