[pick](Variant) variant fallthrough with inverted index (#40070)

backport #40069
This commit is contained in:
lihangyu
2024-08-29 00:30:37 +08:00
committed by GitHub
parent bb709ad917
commit c3c6a4fc4c
5 changed files with 25 additions and 5 deletions

View File

@ -1412,10 +1412,15 @@ Status SegmentIterator::_init_inverted_index_iterators() {
}
for (auto cid : _schema->column_ids()) {
if (_inverted_index_iterators[cid] == nullptr) {
// Not check type valid, since we need to get inverted index for related variant type when reading the segment.
// If check type valid, we can not get inverted index for variant type, and result nullptr.The result for calling
// get_inverted_index with variant suffix should return corresponding inverted index meta.
bool check_inverted_index_by_type = false;
// Use segment’s own index_meta, for compatibility with future indexing needs to default to lowercase.
RETURN_IF_ERROR(_segment->new_inverted_index_iterator(
_opts.tablet_schema->column(cid),
_segment->_tablet_schema->get_inverted_index(_opts.tablet_schema->column(cid)),
_segment->_tablet_schema->get_inverted_index(_opts.tablet_schema->column(cid),
check_inverted_index_by_type),
_opts, &_inverted_index_iterators[cid]));
}
}

File diff suppressed because one or more lines are too long

View File

@ -169,7 +169,7 @@ suite("regression_test_variant_github_events_p2", "nonConcurrent,p2"){
// build inverted index at middle of loading the data
// ADD INDEX
sql """ ALTER TABLE github_events ADD INDEX idx_var (`v`) USING INVERTED PROPERTIES("parser" = "chinese", "parser_mode" = "fine_grained", "support_phrase" = "true") """
sql """ ALTER TABLE github_events ADD INDEX idx_var (`v`) USING INVERTED PROPERTIES("parser" = "english", "support_phrase" = "true") """
wait_for_latest_op_on_table_finish("github_events", timeout)
// 2022
@ -212,9 +212,11 @@ suite("regression_test_variant_github_events_p2", "nonConcurrent,p2"){
} while (running)
}
// TODO fix compaction issue, this case could be stable
sql """set enable_match_without_inverted_index = false"""
// filter by bloom filter
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' order by 1 limit 10"""
// TODO add test case that some certain columns are materialized in some file while others are not materilized(sparse)
// query with inverted index
qt_sql """select cast(v["payload"]["pull_request"]["additions"] as int) from github_events where v["repo"]["name"] match 'xpressengine' order by 1;"""
qt_sql """select count() from github_events where v["repo"]["name"] match 'apache' order by 1;"""
}

View File

@ -61,6 +61,7 @@ suite("regression_test_variant_with_index", "nonConcurrent"){
properties("replication_num" = "1", "disable_auto_compaction" = "true");
"""
sql """insert into var_with_index values(1, '{"a" : 0, "b": 3}', 'hello world'), (2, '{"a" : 123}', 'world'),(3, '{"a" : 123}', 'hello world')"""
sql """set enable_match_without_inverted_index = false"""
qt_sql_inv_1 """select v["a"] from var_with_index where inv match 'hello' order by k"""
qt_sql_inv_2 """select v["a"] from var_with_index where inv match 'hello' and cast(v['a'] as int) > 0 order by k"""
qt_sql_inv_3 """select * from var_with_index where inv match 'hello' and cast(v["a"] as int) > 0 order by k"""

View File

@ -33,7 +33,9 @@ suite("regression_test_variant_var_index", "p0"){
sql """insert into var_index values(2, '{"a" : 18811, "b" : "hello world", "c" : 1181111}')"""
sql """insert into var_index values(3, '{"a" : 18811, "b" : "hello wworld", "c" : 11111}')"""
sql """insert into var_index values(4, '{"a" : 1234, "b" : "hello xxx world", "c" : 8181111}')"""
sql """set enable_match_without_inverted_index = false"""
qt_sql """select * from var_index where cast(v["a"] as smallint) > 123 and cast(v["b"] as string) match 'hello' and cast(v["c"] as int) > 1024 order by k"""
sql """set enable_match_without_inverted_index = true"""
sql """insert into var_index values(5, '{"a" : 123456789, "b" : 123456, "c" : 8181111}')"""
qt_sql """select * from var_index where cast(v["a"] as int) > 123 and cast(v["b"] as string) match 'hello' and cast(v["c"] as int) > 11111 order by k"""
// insert double/float/array/json