Fixes after review

This commit is contained in:
Dmitry Novik 2023-01-03 16:50:06 +00:00
parent 93cf734b57
commit 6386e83953
5 changed files with 32 additions and 29 deletions

View File

@ -43,7 +43,7 @@ ColumnsWithTypeAndName FunctionNode::getArgumentColumns() const
argument.type = arg->getResultType();
if (auto * constant = arg->as<ConstantNode>())
argument.column = argument.type->createColumnConst(1, constant->getValue());
argument_columns.push_back(argument);
argument_columns.push_back(std::move(argument));
}
return argument_columns;
}

View File

@ -5,9 +5,9 @@
#include <Analyzer/ConstantValue.h>
#include <Analyzer/IQueryTreeNode.h>
#include <Analyzer/ListNode.h>
#include <Common/typeid_cast.h>
#include <Core/ColumnsWithTypeAndName.h>
#include <Core/IResolvedFunction.h>
#include <Common/typeid_cast.h>
#include <Functions/IFunction.h>
namespace DB

View File

@ -59,7 +59,7 @@ class ValidationChecker : public InDepthQueryTreeVisitor<ValidationChecker>
if (!function->isResolved())
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Function {} is not resolved after running {} pass",
function->toAST()->dumpTree(), pass_name);
function->toAST()->formatForErrorMessage(), pass_name);
}
public:

View File

@ -33,6 +33,35 @@ namespace ErrorCodes
extern const int BAD_ARGUMENTS;
}
namespace
{
std::pair<ColumnsWithTypeAndName, bool> getFunctionArguments(const ActionsDAG::NodeRawConstPtrs & children)
{
size_t num_arguments = children.size();
bool all_const = true;
ColumnsWithTypeAndName arguments(num_arguments);
for (size_t i = 0; i < num_arguments; ++i)
{
const auto & child = *children[i];
ColumnWithTypeAndName argument;
argument.column = child.column;
argument.type = child.result_type;
argument.name = child.result_name;
if (!argument.column || !isColumnConst(*argument.column))
all_const = false;
arguments[i] = std::move(argument);
}
return { std::move(arguments), all_const };
}
}
void ActionsDAG::Node::toTree(JSONBuilder::JSONMap & map) const
{
map.add("Node Type", magic_enum::enum_name(type));
@ -250,30 +279,6 @@ const ActionsDAG::Node & ActionsDAG::addFunctionImpl(
return addNode(std::move(node));
}
std::pair<ColumnsWithTypeAndName, bool> ActionsDAG::getFunctionArguments(const NodeRawConstPtrs & children)
{
size_t num_arguments = children.size();
bool all_const = true;
ColumnsWithTypeAndName arguments(num_arguments);
for (size_t i = 0; i < num_arguments; ++i)
{
const auto & child = *children[i];
ColumnWithTypeAndName argument;
argument.column = child.column;
argument.type = child.result_type;
argument.name = child.result_name;
if (!argument.column || !isColumnConst(*argument.column))
all_const = false;
arguments[i] = std::move(argument);
}
return { std::move(arguments), all_const };
}
const ActionsDAG::Node & ActionsDAG::findInOutputs(const std::string & name) const
{
if (const auto * node = tryFindInOutputs(name))

View File

@ -358,8 +358,6 @@ private:
std::string result_name,
bool all_const);
static std::pair<ColumnsWithTypeAndName, bool> getFunctionArguments(const NodeRawConstPtrs & children);
#if USE_EMBEDDED_COMPILER
void compileFunctions(size_t min_count_to_compile_expression, const std::unordered_set<const Node *> & lazy_executed_nodes = {});
#endif