Skip to content

Commit

Permalink
[Pick](Variant) pick 2 prs about bugfix of variant (#33011)
Browse files Browse the repository at this point in the history
* [Fix](Variant) forbit table with variant type doing segment compaction temporarily

TODO fix this corretly in later works

* [Bug](Variant) use lower case name for variant's root, since backend treat parent column as lower case

This PR address the problem as blow:
```
errCode = 2, detailMessage = (172.16.56.137)[CANCELLED]failed to initialize storage reader. tablet=17136, res=[INTERNAL_ERROR]Not found field_name, field_name:Tags.tag_key1, schema:[Thread(8), Tags(9), Source(5), tags.tag_key1(-1), Title(6), Level(3), Time(2), CreateDate(1), Message(7), IP(4), AppId(0)]

```
  • Loading branch information
eldenmoon authored Mar 29, 2024
1 parent 67856d9 commit 3a196c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion be/src/olap/rowset/beta_rowset_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ Status BetaRowsetWriter::_segcompaction_if_necessary() {
// otherwise _segcompacting_cond will never get notified
if (!config::enable_segcompaction || !_context.enable_segcompaction ||
!_context.tablet_schema->cluster_key_idxes().empty() ||
!_check_and_set_is_doing_segcompaction()) {
!_check_and_set_is_doing_segcompaction() ||
_context.tablet_schema->num_variant_columns() > 0) {
return status;
}
if (_segcompaction_status.load() != OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public SlotDescriptor createSlotDesc(TupleDescriptor tupleDesc, SlotReference sl
slotRef = new SlotRef(slotDescriptor);
if (slotReference.hasSubColPath()) {
slotDescriptor.setSubColLables(slotReference.getSubColPath());
slotDescriptor.setMaterializedColumnName(slotRef.getColumnName()
slotDescriptor.setMaterializedColumnName(slotRef.getColumnName().toLowerCase()
+ "." + String.join(".", slotReference.getSubColPath()));
}
}
Expand Down
12 changes: 12 additions & 0 deletions regression-test/data/variant_p0/column_name.out
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@
\N \N
UPPER CASE lower case

-- !sql --
1 {"tag_key1":123456}

-- !sql --
1 {"tag_key1":123456}

-- !sql --
1 {"tag_key1":123456}

-- !sql --
1 {"tag_key1":123456}

8 changes: 7 additions & 1 deletion regression-test/suites/variant_p0/column_name.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ suite("regression_test_variant_column_name", "variant_type"){
// sql """insert into ${table_name} values (6, '{"\\n123": "t123", "\\\"123": "123"}')"""
sql """insert into ${table_name} values (7, '{"AA": "UPPER CASE", "aa": "lower case"}')"""
qt_sql """select cast(v["AA"] as string), cast(v["aa"] as string) from ${table_name} order by k"""


sql "alter table var_column_name rename column v Tags; "
sql """insert into var_column_name values (1, '{"tag_key1" : 123456}')"""
qt_sql "select * from var_column_name where tags['tag_key1'] is not null and cast(Tags['tag_key1' ] as text) = '123456' order by k desc limit 1;"
qt_sql "select * from var_column_name where tags['tag_key1'] is not null and cast(tags['tag_key1' ] as text) = '123456' order by k desc limit 1;"
qt_sql "select * from var_column_name where Tags['tag_key1'] is not null and cast(tags['tag_key1' ] as text) = '123456' order by k desc limit 1;"
qt_sql "select * from var_column_name where Tags['tag_key1'] is not null and cast(Tags['tag_key1' ] as text) = '123456' order by k desc limit 1;"
}

0 comments on commit 3a196c8

Please sign in to comment.