Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fe/src/main/java/org/apache/doris/analysis/LiteralExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public Object getRealValue() {

public abstract boolean isMinValue();

// Only used by partition pruning and the derived class which can be used for pruning
// must handle MaxLiteral.
public abstract int compareLiteral(LiteralExpr expr);

// Returns the string representation of the literal's value. Used when passing
Expand Down
22 changes: 21 additions & 1 deletion fe/src/main/java/org/apache/doris/catalog/PartitionKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,27 @@ public int compareTo(PartitionKey other) {
int other_key_len = other.keys.size();
int min_len = Math.min(this_key_len, other_key_len);
for (int i = 0; i < min_len; ++i) {
int ret = keys.get(i).compareLiteral(other.keys.get(i));
final LiteralExpr oldKey = this.getKeys().get(i);
final LiteralExpr otherOldKey = other.getKeys().get(i);
int ret = 0;
if (oldKey instanceof MaxLiteral || otherOldKey instanceof MaxLiteral) {
ret = oldKey.compareLiteral(otherOldKey);
} else {
final Type destType = Type.getAssignmentCompatibleType(oldKey.getType(), otherOldKey.getType(), false);
try {
LiteralExpr newKey = oldKey;
if (oldKey.getType() != destType) {
newKey = (LiteralExpr) oldKey.castTo(destType);
}
LiteralExpr newOtherKey = otherOldKey;
if (otherOldKey.getType() != destType) {
newOtherKey = (LiteralExpr) otherOldKey.castTo(destType);
}
ret = newKey.compareLiteral(newOtherKey);
} catch (AnalysisException e) {
throw new RuntimeException("Cast error in partition");
}
}
if (0 != ret) {
return ret;
}
Expand Down