diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d6d640dc67..b0fa37dfd6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,7 +21,6 @@ add_subdirectory(common) add_subdirectory(copy) add_subdirectory(main) add_subdirectory(optimizer) -add_subdirectory(parser) add_subdirectory(processor) add_subdirectory(runner) add_subdirectory(storage) diff --git a/test/main/CMakeLists.txt b/test/main/CMakeLists.txt index d328b392c2..e3231177bd 100644 --- a/test/main/CMakeLists.txt +++ b/test/main/CMakeLists.txt @@ -2,7 +2,6 @@ add_kuzu_test(main_test config_test.cpp connection_test.cpp csv_output_test.cpp - exception_test.cpp prepare_test.cpp result_value_test.cpp storage_driver_test.cpp) diff --git a/test/main/exception_test.cpp b/test/main/exception_test.cpp deleted file mode 100644 index cdb0661c76..0000000000 --- a/test/main/exception_test.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "main_test_helper/main_test_helper.h" - -using namespace kuzu::testing; - -TEST_F(ApiTest, Exception) { - std::unique_ptr result; - std::unique_ptr preparedStatement; - - auto parser_error_query = "MATCH (a:person)"; - auto parser_error = "Parser exception: Query must conclude with RETURN clause (line: 1, " - "offset: 0)\n\"MATCH (a:person)\"\n ^^^^^"; - result = conn->query(parser_error_query); - ASSERT_FALSE(result->isSuccess()); - ASSERT_STREQ(result->getErrorMessage().c_str(), parser_error); - preparedStatement = conn->prepare(parser_error_query); - ASSERT_FALSE(preparedStatement->isSuccess()); - ASSERT_STREQ(preparedStatement->getErrorMessage().c_str(), parser_error); - - auto binder_error_query = "MATCH (a:person) RETURN b"; - auto binder_error = "Binder exception: Variable b is not in scope."; - result = conn->query(binder_error_query); - ASSERT_FALSE(result->isSuccess()); - ASSERT_STREQ(result->getErrorMessage().c_str(), binder_error); - preparedStatement = conn->prepare(binder_error_query); - ASSERT_FALSE(preparedStatement->isSuccess()); - ASSERT_STREQ(preparedStatement->getErrorMessage().c_str(), binder_error); - - auto catalog_error_query = "MATCH (a:person) RETURN dummy(n)"; - auto catalog_error = "Catalog exception: DUMMY function does not exist."; - result = conn->query(catalog_error_query); - ASSERT_FALSE(result->isSuccess()); - ASSERT_STREQ(result->getErrorMessage().c_str(), catalog_error); - preparedStatement = conn->prepare(catalog_error_query); - ASSERT_FALSE(preparedStatement->isSuccess()); - ASSERT_STREQ(preparedStatement->getErrorMessage().c_str(), catalog_error); - - auto function_error_query = "MATCH (a:person) RETURN a.age + 'hh'"; - auto function_error = - "Binder exception: Cannot match a built-in function for given function " - "+(INT64,STRING). Supported inputs " - "are\n(INT64,INT64) -> INT64\n(INT32,INT32) -> INT32\n(INT16,INT16) -> " - "INT16\n(DOUBLE,DOUBLE) -> DOUBLE\n(FLOAT,FLOAT) -> " - "FLOAT\n(SERIAL,SERIAL) -> SERIAL\n(INTERVAL,INTERVAL) -> INTERVAL\n(DATE,INT64) -> " - "DATE\n(INT64,DATE) -> DATE\n(DATE,INTERVAL) -> DATE\n(INTERVAL,DATE) -> " - "DATE\n(TIMESTAMP,INTERVAL) -> TIMESTAMP\n(INTERVAL,TIMESTAMP) -> TIMESTAMP\n"; - result = conn->query(function_error_query); - ASSERT_FALSE(result->isSuccess()); - ASSERT_STREQ(result->getErrorMessage().c_str(), function_error); - preparedStatement = conn->prepare(function_error_query); - ASSERT_FALSE(preparedStatement->isSuccess()); - ASSERT_STREQ(preparedStatement->getErrorMessage().c_str(), function_error); -} diff --git a/test/parser/CMakeLists.txt b/test/parser/CMakeLists.txt deleted file mode 100644 index a8d00291ed..0000000000 --- a/test/parser/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_kuzu_test(syntax_error_test syntax_error_test.cpp) diff --git a/test/parser/syntax_error_test.cpp b/test/parser/syntax_error_test.cpp deleted file mode 100644 index 094f059c84..0000000000 --- a/test/parser/syntax_error_test.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "common/exception.h" -#include "gtest/gtest.h" -#include "parser/parser.h" - -using namespace kuzu::parser; -using namespace kuzu::common; -using namespace ::testing; - -class SyntaxErrorTest : public Test { - -public: - static std::string getParsingError(const std::string& input) { - try { - Parser::parseQuery(input); - } catch (const Exception& exception) { return exception.what(); } - return std::string(); - } -}; - -TEST_F(SyntaxErrorTest, QueryNotConcludeWithReturn1) { - std::string expectedException = - "Parser exception: Query must conclude with RETURN clause (line: 1, offset: 0)\n"; - expectedException += "\"MATCH (a:person);\"\n"; - expectedException += " ^^^^^"; - auto input = "MATCH (a:person);"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} - -TEST_F(SyntaxErrorTest, QueryNotConcludeWithReturn2) { - std::string expectedException = - "Parser exception: Query must conclude with RETURN clause (line: 1, offset: 23)\n"; - expectedException += "\"MATCH (a:person) WITH *;\"\n"; - expectedException += " ^"; - auto input = "MATCH (a:person) WITH *;"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} - -TEST_F(SyntaxErrorTest, InvalidNotEqualOperator) { - std::string expectedException = - "Parser exception: Unknown operation '!=' (you probably meant to use '<>', which is " - "the operator for inequality testing.) (line: 1, offset: 22)\n"; - expectedException += "\"MATCH (a) WHERE a.age != 1 RETURN *;\"\n"; - expectedException += " ^^"; - auto input = "MATCH (a) WHERE a.age != 1 RETURN *;"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} - -TEST_F(SyntaxErrorTest, EmptyTable) { - std::string expectedException = - "Parser exception: '' is not a valid token name. Token names cannot be empty or " - "contain any null-bytes (line: 1, offset: 9)\n"; - expectedException += "\"MATCH (a:``) RETURN *;\"\n"; - expectedException += " ^^"; - auto input = "MATCH (a:``) RETURN *;"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} - -TEST_F(SyntaxErrorTest, EmptyProperty) { - std::string expectedException = - "Parser exception: '' is not a valid token name. Token names cannot be empty or " - "contain any null-bytes (line: 1, offset: 18)\n"; - expectedException += "\"MATCH (a) WHERE a.`` != 1 RETURN *;\"\n"; - expectedException += " ^^"; - auto input = "MATCH (a) WHERE a.`` != 1 RETURN *;"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} - -TEST_F(SyntaxErrorTest, ReturnNotAtEnd) { - std::string expectedException = - "Parser exception: RETURN can only be used at the end of the query (line: 1, offset: 0)\n"; - expectedException += "\"RETURN a MATCH (a) RETURN a;\"\n"; - expectedException += " ^^^^^^"; - auto input = "RETURN a MATCH (a) RETURN a;"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} - -TEST_F(SyntaxErrorTest, ConjunctiveComparison) { - std::string expectedException = "Parser exception: Non-binary comparison (e.g. a=b=c) is not " - "supported (line: 1, offset: 69)\n"; - expectedException += "\"MATCH (a:person)<-[e1:knows]-(b:person)-[e2:knows]->(c:person) WHERE " - "b.fName = e1.date = e2.date AND id(a) <> id(c) RETURN COUNT(*);\"\n"; - expectedException += " ^"; - auto input = "MATCH (a:person)<-[e1:knows]-(b:person)-[e2:knows]->(c:person) WHERE b.fName = " - "e1.date = e2.date AND id(a) <> id(c) RETURN COUNT(*);"; - ASSERT_STREQ(expectedException.c_str(), getParsingError(input).c_str()); -} diff --git a/test/test_files/tinysnb/binder_error/binder_error.test b/test/test_files/exceptions/binder/binder_error.test similarity index 92% rename from test/test_files/tinysnb/binder_error/binder_error.test rename to test/test_files/exceptions/binder/binder_error.test index a2f4134fde..cd43478405 100644 --- a/test/test_files/tinysnb/binder_error/binder_error.test +++ b/test/test_files/exceptions/binder/binder_error.test @@ -8,79 +8,71 @@ ---- error Binder exception: Node table PERSON does not exist. - -CASE RepeatedRelName -QUERY MATCH (a:person)-[e1:knows]->(b:person)<-[e1:knows]-(:person) RETURN COUNT(*) ---- error Binder exception: Bind relationship e1 to relationship with same name is not supported. - -CASE RepeatedReturnColumnName -QUERY MATCH (a:person)-[e1:knows]->(b:person) RETURN *, e1 ---- error Binder exception: Multiple result column with the same name e1 are not supported. - -CASE WITHExpressionAliased -QUERY MATCH (a:person)-[e1:knows]->(b:person) WITH a.age RETURN * ---- error Binder exception: Expression in WITH must be aliased (use AS). - -CASE BindToDifferentVariableType1 -QUERY MATCH (a:person)-[e1:knows]->(b:person) WITH e1 AS a MATCH (a) RETURN * ---- error Binder exception: e1 has data type REL. (NODE) was expected. - -CASE BindToDifferentVariableType2 -QUERY MATCH (a:person)-[e1:knows]->(b:person) WITH a.age + 1 AS a MATCH (a) RETURN * ---- error Binder exception: +(a.age,1) has data type INT64. (NODE) was expected. - -CASE BindEmptyStar -QUERY RETURN * ---- error Binder exception: RETURN or WITH * is not allowed when there are no variables in scope. - -CASE BindVariableNotInScope1 -QUERY WITH a MATCH (a:person)-[e1:knows]->(b:person) RETURN * ---- error Binder exception: Variable a is not in scope. - -CASE BindVariableNotInScope2 -QUERY MATCH (a:person)-[e1:knows]->(b:person) WHERE a.age > foo RETURN * ---- error Binder exception: Variable foo is not in scope. +-CASE BindVariableNotInScope3 +-QUERY MATCH (a:person) RETURN b +---- error +Binder exception: Variable b is not in scope. -CASE BindPropertyLookUpOnExpression -QUERY MATCH (a:person)-[e1:knows]->(b:person) RETURN (a.age + 2).age ---- error Binder exception: +(a.age,2) has data type INT64. (NODE,REL,STRUCT) was expected. - -CASE BindPropertyNotExist -QUERY MATCH (a:person)-[e1:knows]->(b:person) RETURN a.foo ---- error Binder exception: Cannot find property foo for a. - -CASE BindPropertyNotExist2 -QUERY Create (a:person {foo:'x'}); ---- error Binder exception: Cannot find property foo for a. - -CASE BindPropertyNotExist3 -QUERY WITH {a: 1} AS s RETURN s.b ---- error Binder exception: Invalid struct field name: B. - -CASE BindIDArithmetic -QUERY MATCH (a:person)-[e1:knows]->(b:person) WHERE id(a) + 1 < id(b) RETURN * ---- error @@ -99,7 +91,6 @@ Binder exception: Cannot match a built-in function for given function +(INTERNAL (TIMESTAMP,INTERVAL) -> TIMESTAMP (INTERVAL,TIMESTAMP) -> TIMESTAMP - -CASE BindDateAddDate -QUERY MATCH (a:person) RETURN a.birthdate + date('2031-02-01') ---- error @@ -118,7 +109,6 @@ Binder exception: Cannot match a built-in function for given function +(DATE,DAT (TIMESTAMP,INTERVAL) -> TIMESTAMP (INTERVAL,TIMESTAMP) -> TIMESTAMP - -CASE BindTimestampArithmetic -QUERY MATCH (a:person) WHERE a.registerTime + 1 < 5 RETURN * ---- error @@ -137,7 +127,6 @@ Binder exception: Cannot match a built-in function for given function +(TIMESTAM (TIMESTAMP,INTERVAL) -> TIMESTAMP (INTERVAL,TIMESTAMP) -> TIMESTAMP - -CASE BindTimestampAddTimestamp -QUERY MATCH (a:person) RETURN a.registerTime + timestamp('2031-02-11 01:02:03'); ---- error @@ -156,68 +145,53 @@ Binder exception: Cannot match a built-in function for given function +(TIMESTAM (TIMESTAMP,INTERVAL) -> TIMESTAMP (INTERVAL,TIMESTAMP) -> TIMESTAMP --CASE BindNonExistingFunction --QUERY MATCH (a:person) WHERE dummy() < 2 RETURN COUNT(*) ----- error -Catalog exception: DUMMY function does not exist. - - -CASE BindFunctionWithWrongNumParams -QUERY MATCH (a:person) WHERE date() < 2 RETURN COUNT(*); ---- error Binder exception: Cannot match a built-in function for given function DATE. Supported inputs are (STRING) -> DATE - -CASE BindFunctionWithWrongParamType -QUERY MATCH (a:person) WHERE date(2012) < 2 RETURN COUNT(*); ---- error Binder exception: Cannot match a built-in function for given function DATE(INT64). Supported inputs are (STRING) -> DATE - -CASE OrderByVariableNotInScope -QUERY MATCH (a:person)-[e1:knows]->(b:person) RETURN SUM(a.age) ORDER BY a.ID; ---- error Binder exception: Order by expression a.ID is not in RETURN or WITH clause. - -CASE NestedAggregation -QUERY MATCH (a:person) RETURN SUM(SUM(a.age)); ---- error Binder exception: Expression SUM(SUM(a.age)) contains nested aggregation. - -CASE OptionalMatchAsFirstMatch -QUERY OPTIONAL MATCH (a:person) RETURN *; ---- error Binder exception: First match clause cannot be optional match. - -CASE OrderByWithoutSkipLimitInWithClause -QUERY MATCH (a:person) WITH a.age AS k ORDER BY k RETURN k ---- error Binder exception: In WITH clause, ORDER BY must be followed by SKIP or LIMIT. - -CASE UnionAllUnmatchedNumberOfExpressions -QUERY MATCH (p:person) RETURN p.age,p.fName UNION ALL MATCH (p1:person) RETURN p1.age ---- error Binder exception: The number of columns to union/union all must be the same. - -CASE UnionAllUnmatchedDataTypesOfExpressions -QUERY MATCH (p:person) RETURN p.fName UNION ALL MATCH (p1:person) RETURN p1.age ---- error Binder exception: p1.age has data type INT64. (STRING) was expected. - -CASE UnionAndUnionAllInSingleQuery -QUERY MATCH (p:person) RETURN p.age UNION ALL MATCH (p1:person) RETURN p1.age UNION MATCH (p1:person) RETURN p1.age ---- error Binder exception: Union and union all can't be used together. - -CASE VarLenExtendZeroLowerBound -QUERY MATCH (a:person)-[:knows*0..5]->(b:person) return count(*) ---- error @@ -228,37 +202,31 @@ Binder exception: Lower and upper bound of a rel must be greater than 0. ---- error Binder exception: Expression hh has data type STRING but expect INT64. Implicit cast is not supported. - -CASE CreateNodeDataTypeMisMatch -QUERY CREATE (a:person {age:'hh'}) ---- error Binder exception: Expression hh has data type STRING but expect INT64. Implicit cast is not supported. - -CASE CreateRelDataTypeMisMatch -QUERY CREATE (a:person)-[:knows {date:12}]->(b:person) ---- error Binder exception: Expression 12 has data type INT64 but expect DATE. Implicit cast is not supported. - -CASE ReadAfterUpdate1 -QUERY MATCH (a:person) SET a.age = 35 WITH a MATCH (a)-[:knows]->(b:person) RETURN a.age ---- error Binder exception: Read after update is not supported. - -CASE ReadAfterUpdate3 -QUERY MATCH (a:person) SET a.age=3 RETURN a.fName ---- error Binder exception: Return/With after update is not supported. - -CASE DeleteNodeProperty -QUERY MATCH (a:person) DELETE a.age ---- error Binder exception: Delete PROPERTY is not supported. - -CASE CreateNodeTableUsedName -QUERY CREATE NODE TABLE person(NAME STRING, ID INT64, PRIMARY KEY(NAME)) ---- error @@ -269,103 +237,71 @@ Binder exception: Node person already exists. ---- error Binder exception: Primary key dummyColName does not match any of the predefined node properties. - --CASE CreateNodeTableInvalidDataType --QUERY CREATE NODE TABLE PERSON(NAME BIGINT, PRIMARY KEY(NAME)) ----- error -Cannot parse dataTypeID: BIGINT - - -CASE CreateNodeTableDuplicatedColumnName -QUERY CREATE NODE TABLE student (id INT64, eyesight double, eyesight double, PRIMARY KEY(id)) ---- error Binder exception: Duplicated column name: eyesight, column name must be unique. - -CASE CopyCSVInvalidParsingOption -QUERY COPY person FROM "person_0_0.csv" (pk=",") ---- error Binder exception: Unrecognized parsing csv option: PK. - -CASE CopyCSVInvalidSchemaName -QUERY COPY university FROM "person_0_0.csv" (pk=",") ---- error Binder exception: Node/Rel university does not exist. - -CASE CopyCSVInvalidEscapeChar -QUERY COPY person FROM "person_0_0.csv" (ESCAPE="..") ---- error Binder exception: Copy csv option value can only be a single character with an optional escape character. - -CASE CreateRelTableUsedName -QUERY CREATE REL TABLE knows ( FROM person TO person) ---- error Binder exception: Rel knows already exists. - -CASE CreateRelTableInvalidNodeTableName -QUERY CREATE REL TABLE knows_post ( FROM person TO post) ---- error Binder exception: Node table post does not exist. - --CASE CreateRelTableInvalidRelMultiplicity --QUERY CREATE REL TABLE knows_post ( FROM person TO person, MANY_LOT) ----- error -Catalog exception: Invalid relMultiplicity string 'MANY_LOT'. - - --CASE CreateRelTableInvalidDataType --QUERY CREATE REL TABLE knows_post ( FROM person TO person, ID SMALLINT, MANY_MANY) ----- error -Cannot parse dataTypeID: SMALLINT - - -CASE CreateRelTableDuplicatedColumnName -QUERY CREATE REL TABLE teaches (FROM person TO person, date DATE, date TIMESTAMP) ---- error Binder exception: Duplicated column name: date, column name must be unique. - -CASE CreateRelTableReservedColumnName -QUERY CREATE REL TABLE teaches (FROM person TO person, _id INT64) ---- error Binder exception: PropertyName: _id is an internal reserved propertyName. - -CASE DropNotExistsTable -QUERY DROP TABLE person1; ---- error Binder exception: Node/Rel person1 does not exist. - -CASE SelfLoopRel -QUERY MATCH (a:person)-[e:knows]->(a) RETURN COUNT(*) ---- error Binder exception: Self-loop rel e is not supported. - -CASE InvalidLimitNumberType -QUERY MATCH (a:person) RETURN a.age LIMIT "abc" ---- error Binder exception: The number of rows to skip/limit must be a non-negative integer. - -CASE NegativeLimitNumber -QUERY MATCH (a:person) RETURN a.age LIMIT -1 ---- error Binder exception: The number of rows to skip/limit must be a non-negative integer. - -CASE DuplicateVariableName -QUERY MATCH (a:person) UNWIND [1,2] AS a RETURN COUNT(*) ---- error Binder exception: Variable a already exists. - -CASE MaxNodeID -QUERY MATCH (a:person) RETURN MIN(a) ---- error @@ -398,104 +334,95 @@ DISTINCT (SERIAL) -> SERIAL ---- error Binder exception: Cannot order by p. Order by node or rel is not supported. - -CASE DropColumnFromNonExistedTable -QUERY alter table person1 drop k ---- error Binder exception: Node/Rel person1 does not exist. - -CASE DropNonExistedColumn -QUERY alter table person drop random ---- error Binder exception: person table doesn't have property: random. - -CASE DropPrimaryKeyColumn -QUERY alter table person drop ID ---- error Binder exception: Cannot drop primary key of a node table. - -CASE AddPropertyDuplicateName -QUERY alter table person add fName STRING ---- error Binder exception: Property: fName already exists. - -CASE AddPropertyUnmatchedDefaultValueType -QUERY alter table person add intCol INT64 DEFAULT '3.2' ---- error Binder exception: Expression 3.2 has data type STRING but expect INT64. Implicit cast is not supported. - -CASE RenameNonExistedTable -QUERY alter table person1 rename to person2 ---- error Binder exception: Node/Rel person1 does not exist. - -CASE RenameTableDuplicateName -QUERY alter table person rename to organisation ---- error Binder exception: Table: organisation already exists. - -CASE RenamePropertyOfNonExistedTable -QUERY alter table person1 rename col1 to col2 ---- error Binder exception: Node/Rel person1 does not exist. - -CASE RenamePropertyDuplicateName -QUERY alter table person rename fName to gender ---- error Binder exception: Property gender already exists in table: person. - -CASE InvalidFixedListChildType -QUERY create node table test1(ID INT64, marks STRING[5], PRIMARY KEY(ID)) ---- error Binder exception: The child type of a fixed list must be a numeric type. Given: STRING. - -CASE InvalidFixedListNumElements -QUERY create node table test1(ID INT64, marks INT64[0], PRIMARY KEY(ID)) ---- error Binder exception: The number of elements in a fixed list must be greater than 0. Given: 0. - -CASE InvalidFixedListSize -QUERY create node table test1(ID INT64, marks INT64[512], PRIMARY KEY(ID)) ---- error Binder exception: Cannot store a fixed list of size 4096 in a page. - --CASE MissingStructFieldType --QUERY create node table test1(ID INT64, description STRUCT(name INT64, age INT35), PRIMARY KEY(ID)) ----- error -Cannot parse dataTypeID: INT35 - - --CASE MissingStructFields --QUERY create node table test1(ID INT64, description STRUCT, PRIMARY KEY(ID)) ----- error -Cannot parse struct type: STRUCT - - -CASE NonPKSerialType -QUERY CREATE NODE TABLE test(ID INT64, seq SERIAL, PRIMARY KEY(ID)) ---- error Binder exception: Serial property in node table must be the primary key. - -CASE AddSerialProperty -QUERY ALTER TABLE person ADD seq SERIAL ---- error Binder exception: Serial property in node table must be the primary key. - -CASE SerialInRelTable -QUERY CREATE REL TABLE test(FROM person TO person, seq SERIAL) ---- error Binder exception: Serial property is not supported in rel table. + +-CASE MatchBuiltIn +-QUERY MATCH (a:person) RETURN a.age + 'hh' +---- error +Binder exception: Cannot match a built-in function for given function +(INT64,STRING). Supported inputs are +(INT64,INT64) -> INT64 +(INT32,INT32) -> INT32 +(INT16,INT16) -> INT16 +(DOUBLE,DOUBLE) -> DOUBLE +(FLOAT,FLOAT) -> FLOAT +(SERIAL,SERIAL) -> SERIAL +(INTERVAL,INTERVAL) -> INTERVAL +(DATE,INT64) -> DATE +(INT64,DATE) -> DATE +(DATE,INTERVAL) -> DATE +(INTERVAL,DATE) -> DATE +(TIMESTAMP,INTERVAL) -> TIMESTAMP +(INTERVAL,TIMESTAMP) -> TIMESTAMP diff --git a/test/test_files/exceptions/catalog/catalog.test b/test/test_files/exceptions/catalog/catalog.test new file mode 100644 index 0000000000..6b703a91dd --- /dev/null +++ b/test/test_files/exceptions/catalog/catalog.test @@ -0,0 +1,19 @@ +-GROUP CatalogErrorTest +-DATASET tinysnb + +-- + +-QUERY MATCH (a:person) RETURN dummy(n) +---- error +Catalog exception: DUMMY function does not exist. + +-CASE BindNonExistingFunction +-QUERY MATCH (a:person) WHERE dummy() < 2 RETURN COUNT(*) +---- error +Catalog exception: DUMMY function does not exist. + +-CASE CreateRelTableInvalidRelMultiplicity +-QUERY CREATE REL TABLE knows_post ( FROM person TO person, MANY_LOT) +---- error +Catalog exception: Invalid relMultiplicity string 'MANY_LOT'. + diff --git a/test/test_files/exceptions/parser/parse_type.test b/test/test_files/exceptions/parser/parse_type.test new file mode 100644 index 0000000000..1b21ec5225 --- /dev/null +++ b/test/test_files/exceptions/parser/parse_type.test @@ -0,0 +1,24 @@ +-GROUP SyntaxErrorTest +-DATASET dummy + +-- + +-CASE MissingStructFieldType +-QUERY create node table test1(ID INT64, description STRUCT(name INT64, age INT35), PRIMARY KEY(ID)) +---- error +Cannot parse dataTypeID: INT35 + +-CASE MissingStructFields +-QUERY create node table test1(ID INT64, description STRUCT, PRIMARY KEY(ID)) +---- error +Cannot parse struct type: STRUCT + +-CASE CreateNodeTableInvalidDataType +-QUERY CREATE NODE TABLE PERSON(NAME BIGINT, PRIMARY KEY(NAME)) +---- error +Cannot parse dataTypeID: BIGINT + +-CASE CreateRelTableInvalidDataType +-QUERY CREATE REL TABLE knows_post ( FROM person TO person, ID SMALLINT, MANY_MANY) +---- error +Cannot parse dataTypeID: SMALLINT diff --git a/test/test_files/exceptions/parser/syntax_error.test b/test/test_files/exceptions/parser/syntax_error.test new file mode 100644 index 0000000000..666e4aad51 --- /dev/null +++ b/test/test_files/exceptions/parser/syntax_error.test @@ -0,0 +1,53 @@ +-GROUP SyntaxErrorTest +-DATASET dummy + +-- + +-CASE QueryNotConcludeWithReturn1 +-QUERY MATCH (a:person); +---- error +Parser exception: Query must conclude with RETURN clause (line: 1, offset: 0) +"MATCH (a:person);" + ^^^^^ + +-CASE QueryNotConcludeWithReturn2 +-QUERY MATCH (a:person) WITH *; +---- error +Parser exception: Query must conclude with RETURN clause (line: 1, offset: 23) +"MATCH (a:person) WITH *;" + ^ + +-CASE InvalidNotEqualOperator) +-QUERY MATCH (a) WHERE a.age != 1 RETURN *; +---- error +Parser exception: Unknown operation '!=' (you probably meant to use '<>', which is the operator for inequality testing.) (line: 1, offset: 22) +"MATCH (a) WHERE a.age != 1 RETURN *;" + ^^ + +-CASE EmptyTable +-QUERY MATCH (a:``) RETURN *; +---- error +Parser exception: '' is not a valid token name. Token names cannot be empty or contain any null-bytes (line: 1, offset: 9) +"MATCH (a:``) RETURN *;" + ^^ + +-CASE EmptyProperty +-QUERY MATCH (a) WHERE a.`` != 1 RETURN *; +---- error +Parser exception: '' is not a valid token name. Token names cannot be empty or contain any null-bytes (line: 1, offset: 18) +"MATCH (a) WHERE a.`` != 1 RETURN *;" + ^^ + +-CASE ReturnNotAtEnd +-QUERY RETURN a MATCH (a) RETURN a; +---- error +Parser exception: RETURN can only be used at the end of the query (line: 1, offset: 0) +"RETURN a MATCH (a) RETURN a;" + ^^^^^^ + +-CASE ConjunctiveComparison +-QUERY MATCH (a:person)<-[e1:knows]-(b:person)-[e2:knows]->(c:person) WHERE b.fName = e1.date = e2.date AND id(a) <> id(c) RETURN COUNT(*); +---- error +Parser exception: Non-binary comparison (e.g. a=b=c) is not supported (line: 1, offset: 69) +"MATCH (a:person)<-[e1:knows]-(b:person)-[e2:knows]->(c:person) WHERE b.fName = e1.date = e2.date AND id(a) <> id(c) RETURN COUNT(*);" + ^ diff --git a/test/test_runner/test_parser.cpp b/test/test_runner/test_parser.cpp index 9889e117a0..6fd36855bd 100644 --- a/test/test_runner/test_parser.cpp +++ b/test/test_runner/test_parser.cpp @@ -95,7 +95,7 @@ std::string TestParser::extractTextBeforeNextStatement(bool ignoreLineBreak) { if (!extractedText.empty()) { extractedText += delimiter; } - extractedText += StringUtils::ltrim(line); + extractedText += line; } return extractedText; }