From f61576fdfade56af35e292985a43a6aa19dcfe1f Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 12 May 2020 02:53:03 +0300 Subject: [PATCH] Fix logical error in convertFieldToType --- src/Interpreters/convertFieldToType.cpp | 4 ++-- .../01277_convert_field_to_type_logical_error.reference | 0 .../0_stateless/01277_convert_field_to_type_logical_error.sql | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/01277_convert_field_to_type_logical_error.reference create mode 100644 tests/queries/0_stateless/01277_convert_field_to_type_logical_error.sql diff --git a/src/Interpreters/convertFieldToType.cpp b/src/Interpreters/convertFieldToType.cpp index 9fc4c3f9d0..3cb774596c 100644 --- a/src/Interpreters/convertFieldToType.cpp +++ b/src/Interpreters/convertFieldToType.cpp @@ -32,9 +32,9 @@ namespace DB namespace ErrorCodes { extern const int ARGUMENT_OUT_OF_BOUND; - extern const int LOGICAL_ERROR; extern const int TYPE_MISMATCH; extern const int TOO_LARGE_STRING_SIZE; + extern const int CANNOT_CONVERT_TYPE; } @@ -201,7 +201,7 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID if (const auto * ptype = typeid_cast *>(&type)) return convertDecimalType(src, *ptype); if (!which_type.isDateOrDateTime() && !which_type.isUUID() && !which_type.isEnum()) - throw Exception{"Logical error: unknown numeric type " + type.getName(), ErrorCodes::LOGICAL_ERROR}; + throw Exception{"Cannot convert field to type " + type.getName(), ErrorCodes::CANNOT_CONVERT_TYPE}; if (which_type.isEnum() && (src.getType() == Field::Types::UInt64 || src.getType() == Field::Types::Int64)) { diff --git a/tests/queries/0_stateless/01277_convert_field_to_type_logical_error.reference b/tests/queries/0_stateless/01277_convert_field_to_type_logical_error.reference new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/queries/0_stateless/01277_convert_field_to_type_logical_error.sql b/tests/queries/0_stateless/01277_convert_field_to_type_logical_error.sql new file mode 100644 index 0000000000..05295575cf --- /dev/null +++ b/tests/queries/0_stateless/01277_convert_field_to_type_logical_error.sql @@ -0,0 +1 @@ +SELECT -2487, globalNullIn(toIntervalMinute(-88074), 'qEkek..'), [-27.537293]; -- { serverError 70 } -- GitLab