Fix crash

This commit is contained in:
alesapin 2020-06-18 12:08:24 +03:00
parent f4037b8f54
commit 760e9a8488

View File

@ -215,9 +215,14 @@ public:
}
};
void replaceConstantExpressions(ASTPtr & node, const Context & context, const NamesAndTypesList & columns, ConstStoragePtr storage)
void replaceConstantExpressions(
ASTPtr & node,
const Context & context,
const NamesAndTypesList & columns,
ConstStoragePtr storage,
const StorageMetadataPtr & metadata_snapshot)
{
auto syntax_result = SyntaxAnalyzer(context).analyze(node, columns, storage);
auto syntax_result = SyntaxAnalyzer(context).analyze(node, columns, storage, metadata_snapshot);
Block block_with_constants = KeyCondition::getBlockWithConstants(node, syntax_result, context);
InDepthNodeVisitor<ReplacingConstantExpressionsMatcher, true> visitor(block_with_constants);
@ -777,7 +782,7 @@ ClusterPtr StorageDistributed::skipUnusedShards(
condition_ast = select.prewhere() ? select.prewhere()->clone() : select.where()->clone();
}
replaceConstantExpressions(condition_ast, context, metadata_snapshot->getColumns().getAll(), shared_from_this());
replaceConstantExpressions(condition_ast, context, metadata_snapshot->getColumns().getAll(), shared_from_this(), metadata_snapshot);
const auto blocks = evaluateExpressionOverConstantCondition(condition_ast, sharding_key_expr);
// Can't get definite answer if we can skip any shards