Skip to content

Commit

Permalink
[fix](catelog) Unifies partition items string (#45669)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

For range partitions, `getItems().toString()` is equal to
`getItemsString`, but for list partitions, there has a `,` between each
item.

The upsert record of binlog is generated via `getItemsString`, but the
getMeta method fetches partition items string via
`getItems().toString()`, which are different in the list partitions, and
the ccr-syncer is unable to identify them.

This PR unifies all partition items string via `getItemsString`.
  • Loading branch information
w41ter authored and Your Name committed Dec 20, 2024
1 parent 0137c8e commit c4ea954
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
6 changes: 1 addition & 5 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -6458,11 +6458,7 @@ private static void getTableMeta(OlapTable olapTable, TGetMetaDBMeta dbMeta) {
long partitionId = partition.getId();
partitionMeta.setId(partitionId);
partitionMeta.setName(partition.getName());
String partitionRange = "";
if (tblPartitionInfo.getType() == PartitionType.RANGE
|| tblPartitionInfo.getType() == PartitionType.LIST) {
partitionRange = tblPartitionInfo.getItem(partitionId).getItems().toString();
}
String partitionRange = tblPartitionInfo.getPartitionRangeString(partitionId);
partitionMeta.setRange(partitionRange);
partitionMeta.setVisibleVersion(partition.getVisibleVersion());
// partitionMeta.setTemp(partition.isTemp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public List<PartitionKey> getItems() {
}

public String getItemsString() {
return toString();
// ATTN: DO NOT EDIT unless unless you explicitly guarantee compatibility
// between different versions.
//
// the ccr syncer depends on this string to identify partitions between two
// clusters (cluster versions may be different).
return getItems().toString();
}

public String getItemsSql() {
Expand Down Expand Up @@ -173,11 +178,6 @@ public int hashCode() {

@Override
public String toString() {
// ATTN: DO NOT EDIT unless unless you explicitly guarantee compatibility
// between different versions.
//
// the ccr syncer depends on this string to identify partitions between two
// clusters (cluster versions may be different).
StringBuilder builder = new StringBuilder();
builder.append("partitionKeys: [");
for (PartitionKey partitionKey : partitionKeys) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public Range<PartitionKey> getItems() {
}

public String getItemsString() {
return toString();
// ATTN: DO NOT EDIT unless unless you explicitly guarantee compatibility
// between different versions.
//
// the ccr syncer depends on this string to identify partitions between two
// clusters (cluster versions may be different).
return partitionKeyRange.toString();
}

public String getItemsSql() {
Expand Down Expand Up @@ -120,11 +125,6 @@ public boolean equals(Object obj) {

@Override
public String toString() {
// ATTN: DO NOT EDIT unless unless you explicitly guarantee compatibility
// between different versions.
//
// the ccr syncer depends on this string to identify partitions between two
// clusters (cluster versions may be different).
return partitionKeyRange.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public ProcResult fetchResult() throws AnalysisException {
}
partitionInfo.add(joiner.join(colNames)); // partition key
partitionInfo.add(
rangePartitionInfo.getItem(esShardPartitions.getPartitionId()).getItems().toString()); // range
rangePartitionInfo.getItem(esShardPartitions.getPartitionId()).getItemsString()); // range
partitionInfo.add("-"); // dis
partitionInfo.add(esShardPartitions.getShardRoutings().size()); // shards
partitionInfo.add(1); // replica num
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private List<Pair<List<Comparable>, TRow>> getPartitionInfosInrernal() throws An
String colNamesStr = joiner.join(colNames);
partitionInfo.add(colNamesStr);
trow.addToColumnValue(new TCell().setStringVal(colNamesStr));
String itemStr = tblPartitionInfo.getItem(partitionId).getItems().toString();
String itemStr = tblPartitionInfo.getPartitionRangeString(partitionId);
partitionInfo.add(itemStr);
trow.addToColumnValue(new TCell().setStringVal(itemStr));
} else {
Expand Down

0 comments on commit c4ea954

Please sign in to comment.