Fix tests.

This commit is contained in:
Nikolai Kochetov 2020-06-20 16:48:21 +03:00
parent a58b152140
commit 819ea4fb89
3 changed files with 10 additions and 3 deletions

View File

@ -77,6 +77,7 @@ namespace ErrorCodes
extern const int UNKNOWN_IDENTIFIER;
extern const int ILLEGAL_PREWHERE;
extern const int LOGICAL_ERROR;
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
}
namespace
@ -103,14 +104,20 @@ bool allowEarlyConstantFolding(const ExpressionActions & actions, const Settings
}
bool sanitizeBlock(Block & block)
bool sanitizeBlock(Block & block, bool throw_if_cannot_create_column)
{
for (auto & col : block)
{
if (!col.column)
{
if (isNotCreatable(col.type->getTypeId()))
{
if (throw_if_cannot_create_column)
throw Exception("Cannot create column of type " + col.type->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
return false;
}
col.column = col.type->createColumn();
}
else if (!col.column->empty())

View File

@ -33,7 +33,7 @@ class ASTSelectQuery;
struct ASTTablesInSelectQueryElement;
/// Create columns in block or return false if not possible
bool sanitizeBlock(Block & block);
bool sanitizeBlock(Block & block, bool throw_if_cannot_create_column = false);
/// ExpressionAnalyzer sources, intermediates and results. It splits data and logic, allows to test them separately.
struct ExpressionAnalyzerData

View File

@ -451,7 +451,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
/// Blocks used in expression analysis contains size 1 const columns for constant folding and
/// null non-const columns to avoid useless memory allocations. However, a valid block sample
/// requires all columns to be of size 0, thus we need to sanitize the block here.
sanitizeBlock(result_header);
sanitizeBlock(result_header, true);
}