Skip to content

Commit

Permalink
fix 2184: add binder errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Oct 13, 2023
1 parent 72dcb79 commit 4bc562b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/binder/bind/bind_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ std::unique_ptr<BoundCreateTableInfo> Binder::bindCreateNodeTableInfo(const Crea
std::unique_ptr<BoundCreateTableInfo> Binder::bindCreateRelTableInfo(const CreateTableInfo* info) {
auto boundProperties = bindProperties(info->propertyNameDataTypes);
for (auto& boundProperty : boundProperties) {
if (boundProperty->getDataType()->getLogicalTypeID() == LogicalTypeID::SERIAL) {
throw BinderException("Serial property is not supported in rel table.");
if (boundProperty->getDataType()->getLogicalTypeID() == LogicalTypeID::SERIAL ||
boundProperty->getDataType()->getLogicalTypeID() == LogicalTypeID::UNION ||
boundProperty->getDataType()->getLogicalTypeID() == LogicalTypeID::STRUCT ||
boundProperty->getDataType()->getLogicalTypeID() == LogicalTypeID::MAP) {
throw BinderException(
StringUtils::string_format("{} property is not supported in rel table.",
LogicalTypeUtils::dataTypeToString(
boundProperty->getDataType()->getLogicalTypeID())));
}
}
auto extraInfo = (ExtraCreateRelTableInfo*)info->extraInfo.get();
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/exceptions/binder/binder_error.test
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ Binder exception: Serial property in node table must be the primary key.
-LOG SerialInRelTable
-STATEMENT CREATE REL TABLE test(FROM person TO person, seq SERIAL)
---- error
Binder exception: Serial property is not supported in rel table.
Binder exception: SERIAL property is not supported in rel table.

-LOG MatchBuiltIn
-STATEMENT MATCH (a:person) RETURN a.age + 'hh'
Expand Down
18 changes: 18 additions & 0 deletions test/test_files/issue/issue.test
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,21 @@
MATCH (t:T)-[:LIKES]->(:Fruit {name: "Apple"}), (t)-[:LIKES]->(:Fruit {name: "Banana"}) return t;
---- 1
{_ID: 0:0, _LABEL: T, name: T1}

-CASE 2184
-STATEMENT CREATE NODE TABLE T(name STRING, PRIMARY KEY(name));
---- ok
-STATEMENT CREATE NODE TABLE T2(name STRING, myprops MAP(STRING,STRING), PRIMARY KEY(name));
---- ok
-STATEMENT CREATE REL TABLE KIND_OF3(FROM T TO T, myprops MAP(STRING,STRING));
---- error
Binder exception: MAP property is not supported in rel table.
-STATEMENT CREATE REL TABLE KIND_OF3(FROM T TO T, myprops SERIAL);
---- error
Binder exception: SERIAL property is not supported in rel table.
-STATEMENT CREATE REL TABLE KIND_OF3(FROM T TO T, myprops STRUCT(v INT64));
---- error
Binder exception: STRUCT property is not supported in rel table.
-STATEMENT CREATE REL TABLE KIND_OF3(FROM T TO T, myprops UNION(v1 STRING, v2 INT64));
---- error
Binder exception: UNION property is not supported in rel table.

0 comments on commit 4bc562b

Please sign in to comment.