Skip to content

Commit

Permalink
Add comment on table creation (#2052)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
  • Loading branch information
JinHai-CN authored Oct 18, 2024
1 parent bd43665 commit e1d7f07
Show file tree
Hide file tree
Showing 53 changed files with 2,798 additions and 2,622 deletions.
2 changes: 1 addition & 1 deletion python/infinity_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def show_columns_type(self):
def show_tables(self):
self.get_all_tables()
return database_result(columns=["database", "table", "type", "column_count", "block_count", "block_capacity",
"segment_count", "segment_capacity"])
"segment_count", "segment_capacity", "comment"])

# index
def create_index(
Expand Down
2 changes: 2 additions & 0 deletions python/restart_test/test_memidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,5 @@ def part2(infinity_obj):
assert len(idx2_files_in_dir) == 1

part2()

infinity_runner.clear()
2 changes: 1 addition & 1 deletion python/test_pysdk/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def _test_show_tables(self, suffix):
print(res)
# check the polars dataframe
assert res.columns == ["database", "table", "type", "column_count", "block_count", "block_capacity",
"segment_count", "segment_capacity"]
"segment_count", "segment_capacity", "comment"]

def _test_create_varchar_table(self, suffix):
"""
Expand Down
76 changes: 34 additions & 42 deletions src/admin/admin_executor.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/executor/operator/physical_drop_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ bool PhysicalDropIndex::Execute(QueryContext *query_context, OperatorState *oper
auto txn = query_context->GetTxn();
Status status = txn->DropIndexByName(*schema_name_, *table_name_, *index_name_, conflict_type_);

if(!status.ok()) {
if (!status.ok()) {
operator_state->status_ = status;
}

// Generate the result
Vector<SharedPtr<ColumnDef>> column_defs = {
MakeShared<ColumnDef>(0, MakeShared<DataType>(LogicalType::kInteger), "OK", std::set<ConstraintType>())};

auto result_table_def_ptr = MakeShared<TableDef>(MakeShared<String>("default_db"), MakeShared<String>("Tables"), column_defs);
auto result_table_def_ptr = TableDef::Make(MakeShared<String>("default_db"), MakeShared<String>("Tables"), nullptr, column_defs);
output_ = MakeShared<DataTable>(result_table_def_ptr, TableType::kDataTable);
operator_state->SetComplete();
return true;
Expand Down
5 changes: 3 additions & 2 deletions src/executor/operator/physical_drop_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ void PhysicalDropSchema::Init() {}
bool PhysicalDropSchema::Execute(QueryContext *query_context, OperatorState *operator_state) {
auto txn = query_context->GetTxn();
Status status = txn->DropDatabase(*schema_name_, conflict_type_);
if(!status.ok()) {
if (!status.ok()) {
operator_state->status_ = status;
}

// Generate the result
Vector<SharedPtr<ColumnDef>> column_defs = {
MakeShared<ColumnDef>(0, MakeShared<DataType>(LogicalType::kInteger), "OK", std::set<ConstraintType>())};

auto result_table_def_ptr = MakeShared<TableDef>(MakeShared<String>("default_db"), MakeShared<String>("Tables"), column_defs);
auto result_table_def_ptr =
TableDef::Make(MakeShared<String>("default_db"), MakeShared<String>("Tables"), nullptr, column_defs);
output_ = MakeShared<DataTable>(result_table_def_ptr, TableType::kDataTable);
operator_state->SetComplete();
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/executor/operator/physical_drop_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ bool PhysicalDropTable::Execute(QueryContext *query_context, OperatorState *oper
cache_mgr->DropTable(*schema_name_, *table_name_);
}

if(!status.ok()) {
if (!status.ok()) {
operator_state->status_ = status;
}

// Generate the result
Vector<SharedPtr<ColumnDef>> column_defs = {
MakeShared<ColumnDef>(0, MakeShared<DataType>(LogicalType::kInteger), "OK", std::set<ConstraintType>())};

auto result_table_def_ptr = MakeShared<TableDef>(MakeShared<String>("default_db"), MakeShared<String>("Tables"), column_defs);
auto result_table_def_ptr = TableDef::Make(MakeShared<String>("default_db"), MakeShared<String>("Tables"), nullptr, column_defs);
output_ = MakeShared<DataTable>(result_table_def_ptr, TableType::kDataTable);
operator_state->SetComplete();
return true;
Expand Down
6 changes: 4 additions & 2 deletions src/executor/operator/physical_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ bool PhysicalInsert::Execute(QueryContext *query_context, OperatorState *operato
SizeT column_count = value_list_[0].size();
SizeT table_collection_column_count = table_entry_->ColumnCount();
if (column_count != table_collection_column_count) {
String error_message = fmt::format("Insert values count{} isn't matched with table column count{}.", column_count, table_collection_column_count);
String error_message =
fmt::format("Insert values count{} isn't matched with table column count{}.", column_count, table_collection_column_count);
UnrecoverableError(error_message);
}

Expand Down Expand Up @@ -86,7 +87,8 @@ bool PhysicalInsert::Execute(QueryContext *query_context, OperatorState *operato
if (operator_state == nullptr) {
// Generate the result table
Vector<SharedPtr<ColumnDef>> column_defs;
SharedPtr<TableDef> result_table_def_ptr = MakeShared<TableDef>(MakeShared<String>("default_db"), MakeShared<String>("Tables"), column_defs);
SharedPtr<TableDef> result_table_def_ptr =
TableDef::Make(MakeShared<String>("default_db"), MakeShared<String>("Tables"), nullptr, column_defs);
output_ = MakeShared<DataTable>(result_table_def_ptr, TableType::kDataTable);
output_->SetResultMsg(std::move(result_msg));
} else {
Expand Down
Loading

0 comments on commit e1d7f07

Please sign in to comment.