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

Add limit to TENSOR size #1427

Merged
merged 1 commit into from
Mar 31, 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
9 changes: 6 additions & 3 deletions src/binder/bind/bind_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ DataType Binder::bindDataType(const std::string& dataType) {
"The number of elements in a fixed list must be greater than 0. Given: " +
std::to_string(boundType.fixedNumElementsInList) + ".");
}
if (Types::getDataTypeSize(boundType) > common::BufferPoolConstants::PAGE_4KB_SIZE) {
throw common::BinderException("The size of fixed list is larger than a "
"DEFAULT_PAGE_SIZE, which is not supported yet.");
auto numElementsPerPage = storage::PageUtils::getNumElementsInAPage(
Types::getDataTypeSize(boundType), true /* hasNull */);
if (numElementsPerPage == 0) {
throw common::BinderException(
StringUtils::string_format("Cannot store a fixed list of size {} in a page.",
Types::getDataTypeSize(boundType)));
}
}
return boundType;
Expand Down
7 changes: 7 additions & 0 deletions test/binder/binder_error_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,10 @@ TEST_F(BinderErrorTest, InvalidFixedListNumElements) {
auto input = "create node table test1(ID INT64, marks INT64[0], PRIMARY KEY(ID))";
ASSERT_STREQ(expectedException.c_str(), getBindingError(input).c_str());
}

TEST_F(BinderErrorTest, InvalidFixedListSize) {
std::string expectedException =
"Binder exception: Cannot store a fixed list of size 4096 in a page.";
auto input = "create node table test1(ID INT64, marks INT64[512], PRIMARY KEY(ID))";
ASSERT_STREQ(expectedException.c_str(), getBindingError(input).c_str());
}