Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Oct 27, 2023
1 parent d7fdb3e commit 2487a2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
26 changes: 1 addition & 25 deletions src/binder/expression_binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ static std::string unsupportedImplicitCastException(
std::shared_ptr<Expression> ExpressionBinder::implicitCastIfNecessary(
const std::shared_ptr<Expression>& expression, common::LogicalTypeID targetTypeID) {
if (LogicalTypeUtils::isNested(targetTypeID)) {
// We don't support casting to nested data type. So instead we validate type match.
if (expression->getDataType().getLogicalTypeID() == common::LogicalTypeID::ANY) {
throw BinderException(stringFormat(
"Cannot resolve recursive data type for expression {}.", expression->toString()));
}
// We don't support casting to nested data type. So instead we validate type match.
if (expression->getDataType().getLogicalTypeID() != targetTypeID) {
throw BinderException(
unsupportedImplicitCastException(*expression, LogicalType{targetTypeID}));
Expand All @@ -110,30 +110,6 @@ std::shared_ptr<Expression> ExpressionBinder::implicitCastIfNecessary(
return implicitCast(expression, targetType);
}

// std::shared_ptr<Expression> ExpressionBinder::implicitCastIfNecessary(
// const std::shared_ptr<Expression>& expression, LogicalTypeID targetTypeID) {
// if (targetTypeID == LogicalTypeID::ANY) {
// tar
// }
//
// assert(targetTypeID != common::LogicalTypeID::ANY);
// if (targetTypeID == LogicalTypeID::ANY ||
// expression->dataType.getLogicalTypeID() == targetTypeID) {
// return expression;
// }
// if (expression->dataType.getLogicalTypeID() == LogicalTypeID::ANY) {
// if (targetTypeID == LogicalTypeID::VAR_LIST) {
// // e.g. len($1) we cannot infer the child type for $1.
// throw BinderException(stringFormat(
// "Cannot resolve recursive data type for expression {}.", expression->toString()));
// }
// resolveAnyDataType(*expression, LogicalType(targetTypeID));
// return expression;
// }
// assert(targetTypeID != LogicalTypeID::VAR_LIST);
// return implicitCast(expression, LogicalType(targetTypeID));
//}

std::shared_ptr<Expression> ExpressionBinder::implicitCast(
const std::shared_ptr<Expression>& expression, const LogicalType& targetType) {
if (VectorCastFunction::hasImplicitCast(expression->dataType, targetType)) {
Expand Down
2 changes: 2 additions & 0 deletions src/function/built_in_vector_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ uint32_t BuiltInVectorFunctions::castSerial(LogicalTypeID targetTypeID) {

// When there is multiple candidates functions, e.g. double + int and double + double for input
// "1.5 + parameter", we prefer the one without any implicit casting i.e. double + double.
// Additionally, we prefer function with string parameter because string is most permissive and can
// be cast to any type.
VectorFunctionDefinition* BuiltInVectorFunctions::getBestMatch(
std::vector<VectorFunctionDefinition*>& functions) {
assert(functions.size() > 1);
Expand Down
2 changes: 0 additions & 2 deletions src/include/binder/expression/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class Expression : public std::enable_shared_from_this<Expression> {

expression_vector splitOnAND();

void tryCast(common::LogicalType);

inline bool operator==(const Expression& rhs) const { return uniqueName == rhs.uniqueName; }

std::string toString() const { return hasAlias() ? alias : toStringInternal(); }
Expand Down
21 changes: 21 additions & 0 deletions test/test_files/tinysnb/exception/list.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@

--

-CASE SetListPropertyError
-STATEMENT MATCH (a:person) SET a.workedHours=['A', 'B']
---- error
Binder exception: Expression LIST_CREATION(A,B) has data type STRING[] but expected INT64[]. Implicit cast is not supported.

-CASE ListFunctionMatchError1
-STATEMENT MATCH (a:person) RETURN array_concat(a.workedHours, a.age)
---- error
Binder exception: Cannot match a built-in function for given function ARRAY_CONCAT(VAR_LIST,INT64). Supported inputs are
(VAR_LIST,VAR_LIST) -> VAR_LIST

-CASE ListFunctionMatchError2
-STATEMENT MATCH (a:person) RETURN array_concat(a.workedHours, ['A'])
---- error
Binder exception: Cannot bind LIST_CONCAT with parameter type INT64[] and STRING[].

-CASE ListFunctionMatchError3
-STATEMENT MATCH (a:person) RETURN [a.age, a.fName]
---- error
Binder exception: Cannot bind LIST_CREATION with parameter type INT64 and STRING.

-CASE ListPrepareError
-STATEMENT MATCH (a:person) RETURN list_sort($1)
---- error
Expand Down

0 comments on commit 2487a2f

Please sign in to comment.