This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new d27e77edda4 [fix](nereids) fix show temp table status in 
ShowTableStatusCommand (#52926)
d27e77edda4 is described below

commit d27e77edda444aef7f23f98c7c72dcc636f681df
Author: starocean999 <[email protected]>
AuthorDate: Wed Jul 9 12:27:43 2025 +0800

    [fix](nereids) fix show temp table status in ShowTableStatusCommand (#52926)
    
    ### What problem does this PR solve?
    
    when show table status, the temp table name is not correctly displayed.
    The temp table name is like [seesion_id]_#TEMP#_[table_name]. When show
    table status, it should only display the table_name not the full
    internal name
---
 .../trees/plans/commands/ShowTableStatusCommand.java      | 15 ++++++++++++++-
 .../nereids/trees/plans/commands/info/AliasInfo.java      |  4 ++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableStatusCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableStatusCommand.java
index b5b0140261e..07455b09245 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableStatusCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTableStatusCommand.java
@@ -25,6 +25,7 @@ import org.apache.doris.catalog.ScalarType;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.ErrorCode;
 import org.apache.doris.common.ErrorReport;
+import org.apache.doris.common.FeNameFormat;
 import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.nereids.analyzer.UnboundSlot;
 import org.apache.doris.nereids.trees.expressions.Expression;
@@ -74,7 +75,12 @@ public class ShowTableStatusCommand extends ShowCommand {
             .build();
 
     private static Map<String, String> ALIAS_COLUMN_MAP = 
ImmutableMap.<String, String>builder()
-            .put("name", "TABLE_NAME")
+            // get temp table display name
+            .put("name", String.format("if(instr(TABLE_NAME, '%s') > 0,"
+                    + "substr(TABLE_NAME, instr(TABLE_NAME, '%s') + 
length('%s')), TABLE_NAME)",
+                            FeNameFormat.TEMPORARY_TABLE_SIGN,
+                            FeNameFormat.TEMPORARY_TABLE_SIGN,
+                            FeNameFormat.TEMPORARY_TABLE_SIGN))
             .put("engine", "ENGINE")
             .put("version", "VERSION")
             .put("row_format", "ROW_FORMAT")
@@ -158,6 +164,13 @@ public class ShowTableStatusCommand extends ShowCommand {
      */
     private ShowResultSet execute(ConnectContext ctx, StmtExecutor executor, 
String whereClause)
             throws AnalysisException {
+        // only fetch temp table in current session
+        String tempTableCondition = String.format("and if(instr(TABLE_NAME, 
'%s') > 0,"
+                + "substr(TABLE_NAME, 1, instr(TABLE_NAME, '%s') - 1) = '%s', 
true)",
+                FeNameFormat.TEMPORARY_TABLE_SIGN,
+                FeNameFormat.TEMPORARY_TABLE_SIGN,
+                ConnectContext.get().getSessionId());
+        whereClause += tempTableCondition;
         List<AliasInfo> selectList = new ArrayList<>();
         ALIAS_COLUMN_MAP.forEach((key, value) -> {
             selectList.add(AliasInfo.of(value, key));
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AliasInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AliasInfo.java
index 7191ccbc6bc..a6b83ee291f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AliasInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AliasInfo.java
@@ -49,7 +49,7 @@ public class AliasInfo {
     @Override
     public String toString() {
         return alias == null || alias.isEmpty()
-                ? String.format("`%s`", name)
-                : String.format("`%s` AS `%s`", name, alias);
+                ? String.format("%s", name)
+                : String.format("%s AS `%s`", name, alias);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to