Skip to content

Commit

Permalink
Add block size constraint in insert test (#437)
Browse files Browse the repository at this point in the history
Added an additional test case in test_insert.py to handle inserts that exceed the block size limit. Also, ensured that the table drop operation is successful in the test. Updated the physical_insert.cpp to throw an error when the number of insert rows is larger than the default block capacity.
  • Loading branch information
loloxwg authored Jan 11, 2024
1 parent 76bc86a commit d71e0de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 13 additions & 1 deletion python/test/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,16 @@ def test_insert_big_embedding_float(self):
assert res.success
res = table_obj.insert([{"c1": [-9999999.988] * 65535}])
assert res.success
db_obj.drop_table("test_insert_big_embedding_float")
res = db_obj.drop_table("test_insert_big_embedding_float")
assert res.success

def test_insert_exceed_block_size(self):
infinity_obj = infinity.connect(REMOTE_HOST)
db_obj = infinity_obj.get_database("default")
db_obj.drop_table("test_insert_exceed_block_size", True)
table_obj = db_obj.create_table("test_insert_exceed_block_size", {
"c1": "float"}, None)
assert table_obj
values = [{"c1": 1} for _ in range(8193)]
res = table_obj.insert(values)
assert res.success is False
8 changes: 7 additions & 1 deletion src/executor/operator/physical_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import data_block;
import third_party;
import expression_evaluator;
import base_expression;
import default_values;

import infinity_exception;
import catalog;
Expand All @@ -44,7 +45,12 @@ bool PhysicalInsert::Execute(QueryContext *query_context, OperatorState *operato
SizeT table_collection_column_count = table_entry_->ColumnCount();
if (column_count != table_collection_column_count) {
Error<ExecutorException>(
fmt::format("Insert values count{} isn't matched with table column count{}.", column_count, table_collection_column_count));
fmt::format("Insert values count {} isn't matched with table column count {}.", column_count, table_collection_column_count));
;
}
if (row_count > DEFAULT_BLOCK_CAPACITY) {
Error<ExecutorException>(
fmt::format("Insert values row count {} is larger than default block capacity {}.", row_count, DEFAULT_BLOCK_CAPACITY));
;
}

Expand Down

1 comment on commit d71e0de

@a11enyan97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool coder!

Please sign in to comment.