mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #45299 from ClickHouse/revert-44882-function-node-validation
Revert "Validate function arguments in query tree"
This commit is contained in:
commit
1682bfe0ab
@ -2,7 +2,6 @@
|
||||
|
||||
#include <Common/SipHash.h>
|
||||
#include <Common/FieldVisitorToString.h>
|
||||
#include <DataTypes/IDataType.h>
|
||||
#include <Analyzer/ConstantNode.h>
|
||||
|
||||
#include <IO/WriteBufferFromString.h>
|
||||
@ -32,15 +31,6 @@ FunctionNode::FunctionNode(String function_name_)
|
||||
children[arguments_child_index] = std::make_shared<ListNode>();
|
||||
}
|
||||
|
||||
const DataTypes & FunctionNode::getArgumentTypes() const
|
||||
{
|
||||
if (!function)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Function {} is not resolved",
|
||||
function_name);
|
||||
return function->getArgumentTypes();
|
||||
}
|
||||
|
||||
ColumnsWithTypeAndName FunctionNode::getArgumentColumns() const
|
||||
{
|
||||
const auto & arguments = getArguments().getNodes();
|
||||
|
@ -85,7 +85,6 @@ public:
|
||||
/// Get arguments node
|
||||
QueryTreeNodePtr & getArgumentsNode() { return children[arguments_child_index]; }
|
||||
|
||||
const DataTypes & getArgumentTypes() const;
|
||||
ColumnsWithTypeAndName getArgumentColumns() const;
|
||||
|
||||
/// Returns true if function node has window, false otherwise
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <Analyzer/FunctionNode.h>
|
||||
#include <Analyzer/InDepthQueryTreeVisitor.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <DataTypes/IDataType.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -62,36 +61,6 @@ class ValidationChecker : public InDepthQueryTreeVisitor<ValidationChecker>
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Function {} is not resolved after running {} pass",
|
||||
function->toAST()->formatForErrorMessage(), pass_name);
|
||||
|
||||
if (function->getFunctionName() == "in")
|
||||
return;
|
||||
|
||||
const auto & expected_arg_types = function->getArgumentTypes();
|
||||
auto actual_arg_columns = function->getArgumentColumns();
|
||||
|
||||
if (expected_arg_types.size() != actual_arg_columns.size())
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Function {} expects {} arguments but has {} after running {} pass",
|
||||
function->toAST()->formatForErrorMessage(),
|
||||
expected_arg_types.size(),
|
||||
actual_arg_columns.size(),
|
||||
pass_name);
|
||||
|
||||
for (size_t i = 0; i < expected_arg_types.size(); ++i)
|
||||
{
|
||||
// Skip lambdas
|
||||
if (WhichDataType(expected_arg_types[i]).isFunction())
|
||||
continue;
|
||||
|
||||
if (!expected_arg_types[i]->equals(*actual_arg_columns[i].type))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Function {} expects {} argument to have {} type but receives {} after running {} pass",
|
||||
function->toAST()->formatForErrorMessage(),
|
||||
i,
|
||||
expected_arg_types[i]->getName(),
|
||||
actual_arg_columns[i].type->getName(),
|
||||
pass_name);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user