Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2184: add binding errors #2206

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.