Skip to content

Commit

Permalink
branch-3.0: [fix](build index)Fix build index empty index file on ren…
Browse files Browse the repository at this point in the history
…amed column (apache#43392)

Cherry-picked from apache#43336

Co-authored-by: qiye <[email protected]>
  • Loading branch information
github-actions[bot] and qidaye authored Nov 7, 2024
1 parent d9495eb commit 12ced58
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
27 changes: 20 additions & 7 deletions be/src/olap/task/index_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ Status IndexBuilder::update_inverted_index_info() {
auto column_name = t_inverted_index.columns[0];
auto column_idx = output_rs_tablet_schema->field_index(column_name);
if (column_idx < 0) {
LOG(WARNING) << "referenced column was missing. "
<< "[column=" << column_name << " referenced_column=" << column_idx
<< "]";
continue;
if (!t_inverted_index.column_unique_ids.empty()) {
auto column_unique_id = t_inverted_index.column_unique_ids[0];
column_idx = output_rs_tablet_schema->field_index(column_unique_id);
}
if (column_idx < 0) {
LOG(WARNING) << "referenced column was missing. "
<< "[column=" << column_name
<< " referenced_column=" << column_idx << "]";
continue;
}
}
auto column = output_rs_tablet_schema->column(column_idx);
const auto* index_meta = output_rs_tablet_schema->get_inverted_index(column);
Expand Down Expand Up @@ -498,9 +504,16 @@ Status IndexBuilder::_write_inverted_index_data(TabletSchemaSPtr tablet_schema,
auto column_name = inverted_index.columns[0];
auto column_idx = tablet_schema->field_index(column_name);
if (column_idx < 0) {
LOG(WARNING) << "referenced column was missing. "
<< "[column=" << column_name << " referenced_column=" << column_idx << "]";
continue;
if (!inverted_index.column_unique_ids.empty()) {
auto column_unique_id = inverted_index.column_unique_ids[0];
column_idx = tablet_schema->field_index(column_unique_id);
}
if (column_idx < 0) {
LOG(WARNING) << "referenced column was missing. "
<< "[column=" << column_name << " referenced_column=" << column_idx
<< "]";
continue;
}
}
auto column = tablet_schema->column(column_idx);
auto writer_sign = std::make_pair(segment_idx, index_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
// under the License.


suite("test_match_without_index", "p0") {
suite("test_match_without_index_fault_injection", "nonConcurrent") {

def testTable = "test_match_without_index"
def testTable = "test_match_without_index_fault_injection"
sql "DROP TABLE IF EXISTS ${testTable}"
sql """
CREATE TABLE ${testTable} (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ suite("test_index_change_on_renamed_column") {
assertEquals(show_result[0][2], "idx_s")

qt_select2 """ SELECT * FROM ${tableName} order by id; """
qt_select3 """ SELECT * FROM ${tableName} where s1 match 'welcome'; """
qt_select3 """ SELECT /*+ SET_VAR(enable_inverted_index_query = true) */ * FROM ${tableName} where s1 match 'welcome'; """

def tablets = sql_return_maparray """ show tablets from ${tableName}; """
String tablet_id = tablets[0].TabletId
Expand Down

0 comments on commit 12ced58

Please sign in to comment.