diff --git a/dbms/src/Core/Block.cpp b/dbms/src/Core/Block.cpp index 4d3889da8b9..c969e3256da 100644 --- a/dbms/src/Core/Block.cpp +++ b/dbms/src/Core/Block.cpp @@ -1,4 +1,5 @@ #include +#include #include @@ -409,10 +410,16 @@ static ReturnType checkBlockStructure(const Block & lhs, const Block & rhs, cons return on_error("Block structure mismatch in " + context_description + " stream: different columns:\n" + lhs.dumpStructure() + "\n" + rhs.dumpStructure(), ErrorCodes::BLOCKS_HAVE_DIFFERENT_STRUCTURE); - if (actual.column->isColumnConst() && expected.column->isColumnConst() - && static_cast(*actual.column).getField() != static_cast(*expected.column).getField()) - return on_error("Block structure mismatch in " + context_description + " stream: different values of constants", - ErrorCodes::BLOCKS_HAVE_DIFFERENT_STRUCTURE); + if (actual.column->isColumnConst() && expected.column->isColumnConst()) + { + Field actual_value = static_cast(*actual.column).getField(); + Field expected_value = static_cast(*expected.column).getField(); + + if (actual_value != expected_value) + return on_error("Block structure mismatch in " + context_description + " stream: different values of constants, actual: " + + applyVisitor(FieldVisitorToString(), actual_value) + ", expected: " + applyVisitor(FieldVisitorToString(), expected_value), + ErrorCodes::BLOCKS_HAVE_DIFFERENT_STRUCTURE); + } } return ReturnType(true); diff --git a/dbms/src/Functions/FunctionsMiscellaneous.cpp b/dbms/src/Functions/FunctionsMiscellaneous.cpp index 33abc2dfd41..7e9fcf1c5e2 100644 --- a/dbms/src/Functions/FunctionsMiscellaneous.cpp +++ b/dbms/src/Functions/FunctionsMiscellaneous.cpp @@ -338,9 +338,11 @@ public: { const auto & elem = block.getByPosition(arguments[0]); + /// Note that the result is not a constant, because it contains block size. + block.getByPosition(result).column = DataTypeString().createColumnConst(block.rows(), - elem.type->getName() + ", " + elem.column->dumpStructure()); + elem.type->getName() + ", " + elem.column->dumpStructure())->convertToFullColumnIfConst(); } };