xiaokang commented on code in PR #31051:
URL: https://github.com/apache/doris/pull/31051#discussion_r1493950164
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/IndexDef.java:
##########
@@ -224,12 +224,16 @@ public void checkColumn(Column column, KeysType keysType,
boolean enableUniqueKe
throw new AnalysisException(colType + " is not supported in "
+ indexType.toString() + " index. "
+ "invalid index: " + indexName);
}
- if (!column.isKey()
- && ((keysType == KeysType.UNIQUE_KEYS &&
!enableUniqueKeyMergeOnWrite)
- || keysType == KeysType.AGG_KEYS)) {
- throw new AnalysisException(indexType.toString()
- + " index only used in columns of DUP_KEYS/UNIQUE_KEYS MOW
table or key columns of all table."
- + " invalid index: " + indexName);
+ if (!column.isKey()) {
+ if (keysType == KeysType.AGG_KEYS) {
+ throw new AnalysisException("index should only be used in
columns of DUP_KEYS/UNIQUE_KEYS table"
+ + " or key columns of AGG_KEYS table. invalid index: "
+ indexName);
+ } else if (keysType == KeysType.UNIQUE_KEYS &&
!enableUniqueKeyMergeOnWrite
+ && indexType == IndexType.INVERTED &&
properties != null
Review Comment:
I tested and found that index can be used for value columns of mor unique
table, since there is a guard for possible wrong result:
`_should_push_down_value_predicates()`.
```
BetaRowsetReader::get_segment_iterators(...) {
// ...
if (_should_push_down_value_predicates()) {
if (_read_context->value_predicates != nullptr) {
_read_options.column_predicates.insert(_read_options.column_predicates.end(),
_read_context->value_predicates->begin(),
_read_context->value_predicates->end());
for (auto pred : *(_read_context->value_predicates)) {
if
(_read_options.col_id_to_predicates.count(pred->column_id()) < 1) {
_read_options.col_id_to_predicates.insert(
{pred->column_id(),
std::make_shared<AndBlockColumnPredicate>()});
}
auto single_column_block_predicate = new
SingleColumnBlockPredicate(pred);
_read_options.col_id_to_predicates[pred->column_id()]->add_column_predicate(
single_column_block_predicate);
}
}
}
// ...
}
bool BetaRowsetReader::_should_push_down_value_predicates() const {
// if unique table with rowset [0-x] or [0-1] [2-y] [...],
// value column predicates can be pushdown on rowset [0-x] or [2-y],
[2-y]
// must be compaction, not overlapping and don't have sequence column
return _rowset->keys_type() == UNIQUE_KEYS &&
(((_rowset->start_version() == 0 || _rowset->start_version() ==
2) &&
!_rowset->_rowset_meta->is_segments_overlapping() &&
_read_context->sequence_id_idx == -1) ||
_read_context->enable_unique_key_merge_on_write);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]