Skip to content

Commit

Permalink
[Fix](Variant) fix variant with not null
Browse files Browse the repository at this point in the history
ignore null bitmap for not null and make subcolumn access slots always nullable
  • Loading branch information
eldenmoon committed Mar 14, 2024
1 parent 684766e commit b669057
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 2 additions & 4 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1504,8 +1504,7 @@ Status VariantRootColumnIterator::next_batch(size_t* n, vectorized::MutableColum
}
}
// fill nullmap
if (root_column->is_nullable()) {
DCHECK(dst->is_nullable());
if (root_column->is_nullable() && dst->is_nullable()) {
vectorized::ColumnUInt8& dst_null_map =
assert_cast<vectorized::ColumnNullable&>(*dst).get_null_map_column();
vectorized::ColumnUInt8& src_null_map =
Expand Down Expand Up @@ -1538,8 +1537,7 @@ Status VariantRootColumnIterator::read_by_rowids(const rowid_t* rowids, const si
}
}
// fill nullmap
if (root_column->is_nullable()) {
DCHECK(dst->is_nullable());
if (root_column->is_nullable() && dst->is_nullable()) {
vectorized::ColumnUInt8& dst_null_map =
assert_cast<vectorized::ColumnNullable&>(*dst).get_null_map_column();
vectorized::ColumnUInt8& src_null_map =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,19 @@ public SlotDescriptor createSlotDesc(TupleDescriptor tupleDesc, SlotReference sl
slotDescriptor.setLabel(slotReference.getName());
} else {
slotRef = new SlotRef(slotDescriptor);
if (slotReference.hasSubColPath()) {
slotDescriptor.setSubColLables(slotReference.getSubColPath());
slotDescriptor.setMaterializedColumnName(slotRef.getColumnName()
+ "." + String.join(".", slotReference.getSubColPath()));
}
}
slotRef.setTable(table);
slotRef.setLabel(slotReference.getName());
this.addExprIdSlotRefPair(slotReference.getExprId(), slotRef);
slotDescriptor.setIsNullable(slotReference.nullable());
if (slotReference.hasSubColPath()) {
slotDescriptor.setSubColLables(slotReference.getSubColPath());
slotDescriptor.setMaterializedColumnName(slotRef.getColumnName()
+ "." + String.join(".", slotReference.getSubColPath()));
// always nullable at present
slotDescriptor.setIsNullable(true);
} else {
slotDescriptor.setIsNullable(slotReference.nullable());
}
return slotDescriptor;
}

Expand Down
3 changes: 2 additions & 1 deletion regression-test/suites/variant_github_events_p0/load.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ suite("regression_test_variant_github_events_p0", "nonConcurrent"){
sql """
CREATE TABLE IF NOT EXISTS ${table_name} (
k bigint,
v variant,
v variant not null,
INDEX idx_var(v) USING INVERTED PROPERTIES("parser" = "english") COMMENT ''
)
DUPLICATE KEY(`k`)
Expand All @@ -79,5 +79,6 @@ suite("regression_test_variant_github_events_p0", "nonConcurrent"){
load_json_data.call(table_name, """${getS3Url() + '/regression/gharchive.m/2022-11-07-23.json'}""")
// TODO fix compaction issue, this case could be stable
qt_sql """select cast(v["payload"]["pull_request"]["additions"] as int) from github_events where cast(v["repo"]["name"] as string) = 'xpressengine/xe-core' order by 1;"""
qt_sql """select * from github_events where cast(v["repo"]["name"] as string) = 'xpressengine/xe-core' limit 10"""
// TODO add test case that some certain columns are materialized in some file while others are not materilized(sparse)
}

0 comments on commit b669057

Please sign in to comment.