Better exception message #9810

This commit is contained in:
Alexey Milovidov 2020-04-12 05:51:56 +03:00
parent fd9e3e3b34
commit d43903211a

View File

@ -2394,9 +2394,16 @@ protected:
DataTypePtr getReturnType(const ColumnsWithTypeAndName & arguments) const override DataTypePtr getReturnType(const ColumnsWithTypeAndName & arguments) const override
{ {
const auto type_col = checkAndGetColumnConst<ColumnString>(arguments.back().column.get()); const auto & column = arguments.back().column;
if (!column)
throw Exception("Second argument to " + getName() + " must be a constant string describing type."
" Instead there is non-constant column of type " + arguments.back().type->getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
const auto type_col = checkAndGetColumnConst<ColumnString>(column.get());
if (!type_col) if (!type_col)
throw Exception("Second argument to " + getName() + " must be a constant string describing type", throw Exception("Second argument to " + getName() + " must be a constant string describing type."
" Instead there is a column with the following structure: " + column->dumpStructure(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
return DataTypeFactory::instance().get(type_col->getValue<String>()); return DataTypeFactory::instance().get(type_col->getValue<String>());