Skip to content

Commit

Permalink
Fix on review
Browse files Browse the repository at this point in the history
  • Loading branch information
manh9203 committed Apr 24, 2024
1 parent f4e44b3 commit f87fcfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions src/binder/bind/read/bind_in_query_call.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "binder/binder.h"
#include "binder/expression/expression_util.h"
#include "binder/expression/literal_expression.h"
#include "binder/expression_visitor.h"
#include "binder/query/reading_clause/bound_in_query_call.h"
#include "catalog/catalog.h"
#include "common/exception/binder.h"
Expand All @@ -28,11 +27,13 @@ std::unique_ptr<BoundReadingClause> Binder::bindInQueryCall(const ReadingClause&
children.push_back(expressionBinder.bindExpression(*childExpr));
}
TableFunction tableFunction;
std::vector<Value> inputValues;
std::vector<LogicalType> inputTypes;
for (auto& child : children) {
ExpressionUtil::validateExpressionType(*child, ExpressionType::LITERAL);
auto literalExpr = child->constPtrCast<LiteralExpression>();
inputTypes.push_back(literalExpr->getDataType());
inputValues.push_back(*literalExpr->getValue());
}
auto catalogSet = clientContext->getCatalog()->getFunctions(clientContext->getTx());
auto functionEntry = BuiltInFunctionsUtils::getFunctionCatalogEntry(functionName, catalogSet);
Expand All @@ -41,18 +42,9 @@ std::unique_ptr<BoundReadingClause> Binder::bindInQueryCall(const ReadingClause&
}
auto func = BuiltInFunctionsUtils::matchFunction(functionName, inputTypes, functionEntry);
tableFunction = *func->constPtrCast<TableFunction>();
std::vector<Value> inputValues;
for (auto i = 0u; i < children.size(); ++i) {
auto parameterTypeID = tableFunction.parameterTypeIDs[i];
auto parameterType = parameterTypeID == LogicalTypeID::RDF_VARIANT ?
*LogicalType::RDF_VARIANT() :
LogicalType(parameterTypeID);
auto childAfterCast = expressionBinder.implicitCastIfNecessary(children[i], parameterType);
if (ExpressionVisitor::needFold(*childAfterCast)) {
childAfterCast = expressionBinder.foldExpression(childAfterCast);
}
auto literalExpr = childAfterCast->constPtrCast<LiteralExpression>();
inputValues.push_back(*literalExpr->getValue());
ExpressionUtil::validateDataType(*children[i], parameterTypeID);
}
auto bindInput = function::TableFuncBindInput();
bindInput.inputs = std::move(inputValues);
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/tinysnb/call/call.test
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Binder exception: Cannot match a built-in function for given function table_info
-LOG WrongParameterType
-STATEMENT CALL show_connection(123) RETURN *
---- error
Catalog exception: Table: 123 does not exist.
Binder exception: 123 has data type INT64 but STRING was expected.

-LOG WrongParameterExprType
-STATEMENT CALL show_connection(upper("person")) RETURN *
Expand Down

0 comments on commit f87fcfd

Please sign in to comment.