Skip to content

Commit

Permalink
[BugFix] Increase column_with_row column length limit to MAX_VARCHAR_…
Browse files Browse the repository at this point in the history
…LENGTH (StarRocks#38663)

Signed-off-by: Binglin Chang <decstery@gmail.com>
  • Loading branch information
decster authored Jan 9, 2024
1 parent c99d523 commit 794c426
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
3 changes: 1 addition & 2 deletions be/src/storage/tablet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,8 +1333,7 @@ Status TabletManager::_create_tablet_meta_unlocked(const TCreateTabletReq& reque
column.__set_column_name(Schema::FULL_ROW_COLUMN);
TColumnType ctype;
ctype.__set_type(TPrimitiveType::VARCHAR);
//TODO
ctype.__set_len(65535);
ctype.__set_len(TypeDescriptor::MAX_VARCHAR_LENGTH);
column.__set_column_type(ctype);
column.__set_aggregation_type(TAggregationType::REPLACE);
column.__set_is_allow_null(false);
Expand Down
11 changes: 9 additions & 2 deletions be/test/storage/tablet_updates_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2548,11 +2548,18 @@ TEST_F(TabletUpdatesTest, get_missing_version_ranges) {
TEST_F(TabletUpdatesTest, column_with_row_update) {
auto tablet = create_tablet_column_with_row(rand(), rand());
std::vector<int64_t> keys;
int N = 100;
int N = 20;
for (int i = 0; i < N; i++) {
keys.push_back(i);
}
ASSERT_TRUE(tablet->rowset_commit(1, create_rowset_column_with_row(tablet, keys)).ok());
auto old_enable_check_string_lengths = config::enable_check_string_lengths;
config::enable_check_string_lengths = true;
auto rs_err = create_rowset_column_with_row(tablet, keys, true);
ASSERT_FALSE(rs_err.ok());
config::enable_check_string_lengths = old_enable_check_string_lengths;
auto rs = create_rowset_column_with_row(tablet, keys, false);
ASSERT_TRUE(rs.ok());
ASSERT_TRUE(tablet->rowset_commit(1, rs.value()).ok());
}

void TabletUpdatesTest::test_get_rowsets_for_incremental_snapshot(const std::vector<int64_t>& versions,
Expand Down
18 changes: 13 additions & 5 deletions be/test/storage/tablet_updates_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ class TabletUpdatesTest : public testing::Test {
return *writer->build();
}

RowsetSharedPtr create_rowset_column_with_row(const TabletSharedPtr& tablet, const vector<int64_t>& keys) {
StatusOr<RowsetSharedPtr> create_rowset_column_with_row(const TabletSharedPtr& tablet, const vector<int64_t>& keys,
bool large_var_column = false) {
RowsetWriterContext writer_context;
RowsetId rowset_id = StorageEngine::instance()->next_rowset_id();
writer_context.rowset_id = rowset_id;
Expand All @@ -301,13 +302,19 @@ class TabletUpdatesTest : public testing::Test {
}
auto schema_without_full_row_column = std::make_unique<Schema>(&schema, cids);
auto chunk = ChunkHelper::new_chunk(*schema_without_full_row_column, nkeys);
string varchar_value;
if (large_var_column) {
varchar_value = std::string(1024 * 1024, 'a');
} else {
varchar_value = std::string(1024, 'a');
}
auto& cols = chunk->columns();
for (int64_t key : keys) {
cols[0]->append_datum(Datum(key));
cols[1]->append_datum(Datum((int16_t)(nkeys - 1 - key)));
cols[2]->append_datum(Datum((int32_t)(key)));
cols[2]->append_datum(Datum(Slice(varchar_value)));
}
CHECK_OK(writer->flush_chunk(*chunk));
RETURN_IF_ERROR(writer->flush_chunk(*chunk));
return *writer->build();
}

Expand Down Expand Up @@ -534,14 +541,15 @@ class TabletUpdatesTest : public testing::Test {
TColumn k3;
k3.column_name = "v2";
k3.__set_is_key(false);
k3.column_type.type = TPrimitiveType::INT;
k3.column_type.type = TPrimitiveType::VARCHAR;
k3.column_type.len = TypeDescriptor::MAX_VARCHAR_LENGTH;
request.tablet_schema.columns.push_back(k3);

TColumn row;
row.column_name = Schema::FULL_ROW_COLUMN;
TColumnType ctype;
ctype.__set_type(TPrimitiveType::VARCHAR);
ctype.__set_len(65535);
ctype.__set_len(TypeDescriptor::MAX_VARCHAR_LENGTH);
row.__set_column_type(ctype);
row.__set_aggregation_type(TAggregationType::REPLACE);
row.__set_is_allow_null(false);
Expand Down

0 comments on commit 794c426

Please sign in to comment.