diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java b/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java index c2dee8d62fc9ca..63a1bf651200ea 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/PartitionsProcDir.java @@ -104,6 +104,7 @@ */ public class PartitionsProcDir implements ProcDirInterface { private static final Logger LOG = LogManager.getLogger(PartitionsProcDir.class); + static final String CLOUD_STORAGE_MEDIUM_DISPLAY = "OBJECT_STORAGE"; public static final ImmutableList TITLE_NAMES = new ImmutableList.Builder() .add("PartitionId").add("PartitionName") @@ -408,6 +409,14 @@ public List getPartitionInfosForTvf() throws AnalysisException { return partitionInfosInrernal.stream().map(pair -> pair.second).collect(Collectors.toList()); } + public static String getStorageMediumDisplay(String storageMedium) { + return Config.isCloudMode() ? CLOUD_STORAGE_MEDIUM_DISPLAY : storageMedium; + } + + public static String getReplicaAllocationDisplay(String replicaAllocation) { + return Config.isCloudMode() ? FeConstants.null_string : replicaAllocation; + } + private List getPartitionVersions(OlapTable olapTable, List partitionIds) throws AnalysisException { List partitionVersions; @@ -579,8 +588,9 @@ private List, TRow>> getPartitionInfosInrernal() throws An trow.addToColumnValue(new TCell().setIntVal(totalReplicaNum)); DataProperty dataProperty = tblPartitionInfo.getDataProperty(partitionId); - partitionInfo.add(dataProperty.getStorageMedium().name()); - trow.addToColumnValue(new TCell().setStringVal(dataProperty.getStorageMedium().name())); + String storageMedium = getStorageMediumDisplay(dataProperty.getStorageMedium().name()); + partitionInfo.add(storageMedium); + trow.addToColumnValue(new TCell().setStringVal(storageMedium)); String cooldownTimeStr = TimeUtils.longToTimeString(dataProperty.getCooldownTimeMs()); partitionInfo.add(cooldownTimeStr); trow.addToColumnValue(new TCell().setStringVal(cooldownTimeStr)); @@ -599,7 +609,8 @@ private List, TRow>> getPartitionInfosInrernal() throws An partitionInfo.add(isInMemory); trow.addToColumnValue(new TCell().setBoolVal(isInMemory)); // replica allocation - String replica = tblPartitionInfo.getReplicaAllocation(partitionId).toCreateStmt(); + String replica = getReplicaAllocationDisplay( + tblPartitionInfo.getReplicaAllocation(partitionId).toCreateStmt()); partitionInfo.add(replica); trow.addToColumnValue(new TCell().setStringVal(replica)); diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java index c980154e60c342..d206dfc485646b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java @@ -1650,15 +1650,17 @@ private static void partitionsForInternalCatalog(UserIdentity currentUserIdentit + sizePair.second; trow.addToColumnValue(new TCell().setStringVal(readableDateSize)); // REMOTE_DATA_SIZE trow.addToColumnValue(new TCell().setStringVal(partition.getState().toString())); // STATE - trow.addToColumnValue(new TCell().setStringVal(partitionInfo.getReplicaAllocation(partitionId) - .toCreateStmt())); // REPLICA_ALLOCATION + String replicaAllocation = PartitionsProcDir.getReplicaAllocationDisplay( + partitionInfo.getReplicaAllocation(partitionId).toCreateStmt()); + trow.addToColumnValue(new TCell().setStringVal(replicaAllocation)); // REPLICA_ALLOCATION trow.addToColumnValue(new TCell().setIntVal(partitionInfo.getReplicaAllocation(partitionId) .getTotalReplicaNum())); // REPLICA_NUM trow.addToColumnValue(new TCell().setStringVal(partitionInfo .getStoragePolicy(partitionId))); // STORAGE_POLICY DataProperty dataProperty = partitionInfo.getDataProperty(partitionId); - trow.addToColumnValue(new TCell().setStringVal(dataProperty.getStorageMedium() - .name())); // STORAGE_MEDIUM + String storageMedium = PartitionsProcDir + .getStorageMediumDisplay(dataProperty.getStorageMedium().name()); + trow.addToColumnValue(new TCell().setStringVal(storageMedium)); // STORAGE_MEDIUM trow.addToColumnValue(new TCell().setStringVal(TimeUtils.longToTimeString(dataProperty .getCooldownTimeMs()))); // COOLDOWN_TIME_MS trow.addToColumnValue(new TCell().setStringVal(TimeUtils.longToTimeString(partition diff --git a/fe/fe-core/src/test/java/org/apache/doris/common/proc/PartitionsProcDirTest.java b/fe/fe-core/src/test/java/org/apache/doris/common/proc/PartitionsProcDirTest.java new file mode 100644 index 00000000000000..15d11b3f57d681 --- /dev/null +++ b/fe/fe-core/src/test/java/org/apache/doris/common/proc/PartitionsProcDirTest.java @@ -0,0 +1,61 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.common.proc; + +import org.apache.doris.common.Config; +import org.apache.doris.common.FeConstants; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class PartitionsProcDirTest { + private String originDeployMode; + private String originCloudUniqueId; + + @Before + public void setUp() { + originDeployMode = Config.deploy_mode; + originCloudUniqueId = Config.cloud_unique_id; + Config.deploy_mode = ""; + Config.cloud_unique_id = ""; + } + + @After + public void tearDown() { + Config.deploy_mode = originDeployMode; + Config.cloud_unique_id = originCloudUniqueId; + } + + @Test + public void testDisplayInNonCloudMode() { + Assert.assertEquals("HDD", PartitionsProcDir.getStorageMediumDisplay("HDD")); + Assert.assertEquals("tag.location.default: 1", + PartitionsProcDir.getReplicaAllocationDisplay("tag.location.default: 1")); + } + + @Test + public void testDisplayInCloudMode() { + Config.deploy_mode = "cloud"; + Assert.assertEquals(PartitionsProcDir.CLOUD_STORAGE_MEDIUM_DISPLAY, + PartitionsProcDir.getStorageMediumDisplay("HDD")); + Assert.assertEquals(FeConstants.null_string, + PartitionsProcDir.getReplicaAllocationDisplay("tag.location.default: 1")); + } +}