diff --git a/src/binder/expression_binder.cpp b/src/binder/expression_binder.cpp index 1b1fab6ddb..632d9c6435 100644 --- a/src/binder/expression_binder.cpp +++ b/src/binder/expression_binder.cpp @@ -75,10 +75,10 @@ std::shared_ptr ExpressionBinder::foldExpression( } static std::string unsupportedImplicitCastException( - const Expression& expression, const common::LogicalType& targetType) { + const Expression& expression, const std::string& targetTypeStr) { return stringFormat( "Expression {} has data type {} but expected {}. Implicit cast is not supported.", - expression.toString(), expression.dataType.toString(), targetType.toString()); + expression.toString(), expression.dataType.toString(), targetTypeStr); } std::shared_ptr ExpressionBinder::implicitCastIfNecessary( @@ -90,8 +90,8 @@ std::shared_ptr ExpressionBinder::implicitCastIfNecessary( } // 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})); + throw BinderException(unsupportedImplicitCastException( + *expression, LogicalTypeUtils::toString(targetTypeID))); } return expression; } @@ -123,7 +123,7 @@ std::shared_ptr ExpressionBinder::implicitCast( std::move(bindData), std::move(children), scalarFunction->execFunc, nullptr /* selectFunc */, std::move(uniqueName)); } else { - throw BinderException(unsupportedImplicitCastException(*expression, targetType)); + throw BinderException(unsupportedImplicitCastException(*expression, targetType.toString())); } } diff --git a/test/test_files/tinysnb/function/cast.test b/test/test_files/tinysnb/function/cast.test index f3c5ba9f5c..2f412d38c4 100644 --- a/test/test_files/tinysnb/function/cast.test +++ b/test/test_files/tinysnb/function/cast.test @@ -1319,3 +1319,11 @@ False -STATEMENT RETURN CAST([3,5,2], "int64[]") as foo; ---- 1 [3,5,2] + +-LOG PatternToString +-STATEMENT OPTIONAL MATCH p = (a:person) WHERE a.ID = -1 RETURN cast(nodes(p), "string"); +---- 1 +[] +-STATEMENT OPTIONAL MATCH p = (a:person)-[e:knows]->(:person) WHERE a.ID = -1 RETURN cast(rels(p), "string"); +---- 1 +[] diff --git a/test/test_files/tinysnb/unwind/unwind.test b/test/test_files/tinysnb/unwind/unwind.test index f2ab8ff8fb..a71c54fd67 100644 --- a/test/test_files/tinysnb/unwind/unwind.test +++ b/test/test_files/tinysnb/unwind/unwind.test @@ -15,18 +15,21 @@ Binder exception: Cannot set expression n with type VARIABLE. Expect node or rel -STATEMENT MATCH p = (a:person)-[e:knows*1..2]->(b:person) UNWIND nodes(p) AS n DELETE n; ---- error Binder exception: Cannot delete expression n with type VARIABLE. Expect node or rel pattern. - --LOG unwind14 --STATEMENT MATCH (a:person) WITH collect(a) as b UNWIND b AS d RETURN d; ----- 8 -{_ID: 0:0, _LABEL: person, ID: 0, fName: Alice, gender: 1, isStudent: True, isWorker: False, age: 35, eyeSight: 5.000000, birthdate: 1900-01-01, registerTime: 2011-08-20 11:25:30, lastJobDuration: 3 years 2 days 13:02:00, workedHours: [10,5], usedNames: [Aida], courseScoresPerTerm: [[10,8],[6,7,8]], grades: [96,54,86,92], height: 1.731000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11} -{_ID: 0:1, _LABEL: person, ID: 2, fName: Bob, gender: 2, isStudent: True, isWorker: False, age: 30, eyeSight: 5.100000, birthdate: 1900-01-01, registerTime: 2008-11-03 15:25:30.000526, lastJobDuration: 10 years 5 months 13:00:00.000024, workedHours: [12,8], usedNames: [Bobby], courseScoresPerTerm: [[8,9],[9,10]], grades: [98,42,93,88], height: 0.990000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12} -{_ID: 0:2, _LABEL: person, ID: 3, fName: Carol, gender: 1, isStudent: False, isWorker: True, age: 45, eyeSight: 5.000000, birthdate: 1940-06-22, registerTime: 1911-08-20 02:32:21, lastJobDuration: 48:24:11, workedHours: [4,5], usedNames: [Carmen,Fred], courseScoresPerTerm: [[8,10]], grades: [91,75,21,95], height: 1.000000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a13} -{_ID: 0:3, _LABEL: person, ID: 5, fName: Dan, gender: 2, isStudent: False, isWorker: True, age: 20, eyeSight: 4.800000, birthdate: 1950-07-23, registerTime: 2031-11-30 12:25:30, lastJobDuration: 10 years 5 months 13:00:00.000024, workedHours: [1,9], usedNames: [Wolfeschlegelstein,Daniel], courseScoresPerTerm: [[7,4],[8,8],[9]], grades: [76,88,99,89], height: 1.300000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14} -{_ID: 0:4, _LABEL: person, ID: 7, fName: Elizabeth, gender: 1, isStudent: False, isWorker: True, age: 20, eyeSight: 4.700000, birthdate: 1980-10-26, registerTime: 1976-12-23 11:21:42, lastJobDuration: 48:24:11, workedHours: [2], usedNames: [Ein], courseScoresPerTerm: [[6],[7],[8]], grades: [96,59,65,88], height: 1.463000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a15} -{_ID: 0:5, _LABEL: person, ID: 8, fName: Farooq, gender: 2, isStudent: True, isWorker: False, age: 25, eyeSight: 4.500000, birthdate: 1980-10-26, registerTime: 1972-07-31 13:22:30.678559, lastJobDuration: 00:18:00.024, workedHours: [3,4,5,6,7], usedNames: [Fesdwe], courseScoresPerTerm: [[8]], grades: [80,78,34,83], height: 1.510000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a16} -{_ID: 0:6, _LABEL: person, ID: 9, fName: Greg, gender: 2, isStudent: False, isWorker: False, age: 40, eyeSight: 4.900000, birthdate: 1980-10-26, registerTime: 1976-12-23 04:41:42, lastJobDuration: 10 years 5 months 13:00:00.000024, workedHours: [1], usedNames: [Grad], courseScoresPerTerm: [[10]], grades: [43,83,67,43], height: 1.600000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17} -{_ID: 0:7, _LABEL: person, ID: 10, fName: Hubert Blaine Wolfeschlegelsteinhausenbergerdorff, gender: 2, isStudent: False, isWorker: True, age: 83, eyeSight: 4.900000, birthdate: 1990-11-27, registerTime: 2023-02-21 13:25:30, lastJobDuration: 3 years 2 days 13:02:00, workedHours: [10,11,12,3,4,5,6,7], usedNames: [Ad,De,Hi,Kye,Orlan], courseScoresPerTerm: [[7],[10],[6,7]], grades: [77,64,100,54], height: 1.323000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18} +-STATEMENT UNWIND 1 AS a RETURN a; +---- error +Binder exception: Expression 1 has data type INT64 but expected VAR_LIST. Implicit cast is not supported. +-STATEMENT MATCH p = (a:person)-[e:knows*1..2]->(b:person) UNWIND p AS x RETURN x; +---- error +Binder exception: Expression p has data type RECURSIVE_REL but expected VAR_LIST. Implicit cast is not supported. +-STATEMENT MATCH p = (a:person)-[e:knows*1..1]->(b:person) UNWIND nodes(p) AS x RETURN x.fName, COUNT(*); +---- 7 +Alice|6 +Bob|6 +Carol|6 +Dan|6 +Elizabeth|2 +Farooq|1 +Greg|1 -STATEMENT MATCH (a:person) WITH collect(a) as b UNWIND b AS d RETURN d.*; ---- 8 @@ -165,3 +168,14 @@ Aida|Alice|Bob|Dan 1 2 +-LOG unwind14 +-STATEMENT MATCH (a:person) WITH collect(a) as b UNWIND b AS d RETURN d; +---- 8 +{_ID: 0:0, _LABEL: person, ID: 0, fName: Alice, gender: 1, isStudent: True, isWorker: False, age: 35, eyeSight: 5.000000, birthdate: 1900-01-01, registerTime: 2011-08-20 11:25:30, lastJobDuration: 3 years 2 days 13:02:00, workedHours: [10,5], usedNames: [Aida], courseScoresPerTerm: [[10,8],[6,7,8]], grades: [96,54,86,92], height: 1.731000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11} +{_ID: 0:1, _LABEL: person, ID: 2, fName: Bob, gender: 2, isStudent: True, isWorker: False, age: 30, eyeSight: 5.100000, birthdate: 1900-01-01, registerTime: 2008-11-03 15:25:30.000526, lastJobDuration: 10 years 5 months 13:00:00.000024, workedHours: [12,8], usedNames: [Bobby], courseScoresPerTerm: [[8,9],[9,10]], grades: [98,42,93,88], height: 0.990000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12} +{_ID: 0:2, _LABEL: person, ID: 3, fName: Carol, gender: 1, isStudent: False, isWorker: True, age: 45, eyeSight: 5.000000, birthdate: 1940-06-22, registerTime: 1911-08-20 02:32:21, lastJobDuration: 48:24:11, workedHours: [4,5], usedNames: [Carmen,Fred], courseScoresPerTerm: [[8,10]], grades: [91,75,21,95], height: 1.000000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a13} +{_ID: 0:3, _LABEL: person, ID: 5, fName: Dan, gender: 2, isStudent: False, isWorker: True, age: 20, eyeSight: 4.800000, birthdate: 1950-07-23, registerTime: 2031-11-30 12:25:30, lastJobDuration: 10 years 5 months 13:00:00.000024, workedHours: [1,9], usedNames: [Wolfeschlegelstein,Daniel], courseScoresPerTerm: [[7,4],[8,8],[9]], grades: [76,88,99,89], height: 1.300000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14} +{_ID: 0:4, _LABEL: person, ID: 7, fName: Elizabeth, gender: 1, isStudent: False, isWorker: True, age: 20, eyeSight: 4.700000, birthdate: 1980-10-26, registerTime: 1976-12-23 11:21:42, lastJobDuration: 48:24:11, workedHours: [2], usedNames: [Ein], courseScoresPerTerm: [[6],[7],[8]], grades: [96,59,65,88], height: 1.463000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a15} +{_ID: 0:5, _LABEL: person, ID: 8, fName: Farooq, gender: 2, isStudent: True, isWorker: False, age: 25, eyeSight: 4.500000, birthdate: 1980-10-26, registerTime: 1972-07-31 13:22:30.678559, lastJobDuration: 00:18:00.024, workedHours: [3,4,5,6,7], usedNames: [Fesdwe], courseScoresPerTerm: [[8]], grades: [80,78,34,83], height: 1.510000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a16} +{_ID: 0:6, _LABEL: person, ID: 9, fName: Greg, gender: 2, isStudent: False, isWorker: False, age: 40, eyeSight: 4.900000, birthdate: 1980-10-26, registerTime: 1976-12-23 04:41:42, lastJobDuration: 10 years 5 months 13:00:00.000024, workedHours: [1], usedNames: [Grad], courseScoresPerTerm: [[10]], grades: [43,83,67,43], height: 1.600000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a17} +{_ID: 0:7, _LABEL: person, ID: 10, fName: Hubert Blaine Wolfeschlegelsteinhausenbergerdorff, gender: 2, isStudent: False, isWorker: True, age: 83, eyeSight: 4.900000, birthdate: 1990-11-27, registerTime: 2023-02-21 13:25:30, lastJobDuration: 3 years 2 days 13:02:00, workedHours: [10,11,12,3,4,5,6,7], usedNames: [Ad,De,Hi,Kye,Orlan], courseScoresPerTerm: [[7],[10],[6,7]], grades: [77,64,100,54], height: 1.323000, u: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a18}