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

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 4dc111df984 branch-4.1: [fix](meta info) Fix wrong columns in 
information_schema.columns when a table is missing in describeTables #66678 
(#66721)
4dc111df984 is described below

commit 4dc111df984659cdd5d906f7255c0daf3c19e8e8
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Aug 13 18:38:45 2026 +0800

    branch-4.1: [fix](meta info) Fix wrong columns in 
information_schema.columns when a table is missing in describeTables #66678 
(#66721)
    
    Cherry-picked from #66678
    
    Co-authored-by: yujun <[email protected]>
---
 .../apache/doris/service/FrontendServiceImpl.java  | 17 ++---
 ...st_information_schema_columns_missing_table.out | 21 ++++++
 ...information_schema_columns_missing_table.groovy | 74 ++++++++++++++++++++++
 3 files changed, 104 insertions(+), 8 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java 
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 6795b84cd43..19e8376386a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -972,15 +972,14 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
                 .getCatalogOrException(catalogName, catalog -> new 
TException("Unknown catalog " + catalog))
                 .getDbNullable(dbName);
         if (db != null) {
+            String skipTable = DebugPointUtil.getDebugParamOrDefault(
+                    "FE.describeTables.skipTable", "value", "");
             for (String tableName : tables) {
                 TableIf table = db.getTableNullableIfException(tableName);
-                if (table != null) {
-                    if (table.isTemporary()) {
-                        // because we return all table names to be,
-                        // so when we skip temporary table, we should add a 
offset here
-                        tablesOffset.add(columns.size());
-                        continue;
-                    }
+                if (!skipTable.isEmpty() && tableName.equals(skipTable)) {
+                    table = null;
+                }
+                if (table != null && !table.isTemporary()) {
                     table.readLock();
                     try {
                         List<Column> baseSchema = table.getBaseSchemaOrEmpty();
@@ -1006,8 +1005,10 @@ public class FrontendServiceImpl implements 
FrontendService.Iface {
                     } finally {
                         table.readUnlock();
                     }
-                    tablesOffset.add(columns.size());
                 }
+                // every requested table should have an offset, even if the 
table is missing,
+                // otherwise the BE can not map columns to the correct table 
name.
+                tablesOffset.add(columns.size());
             }
         }
         return result;
diff --git 
a/regression-test/data/information_schema_p0/test_information_schema_columns_missing_table.out
 
b/regression-test/data/information_schema_p0/test_information_schema_columns_missing_table.out
new file mode 100644
index 00000000000..992277e929f
--- /dev/null
+++ 
b/regression-test/data/information_schema_p0/test_information_schema_columns_missing_table.out
@@ -0,0 +1,21 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !baseline --
+tbl_a  tbl_a_c0
+tbl_a  tbl_a_c1
+tbl_a  tbl_a_c2
+tbl_a  tbl_a_c3
+tbl_b  tbl_b_c0
+tbl_b  tbl_b_c1
+tbl_b  tbl_b_c2
+
+-- !skip_tbl_a --
+tbl_b  tbl_b_c0
+tbl_b  tbl_b_c1
+tbl_b  tbl_b_c2
+
+-- !skip_tbl_b --
+tbl_a  tbl_a_c0
+tbl_a  tbl_a_c1
+tbl_a  tbl_a_c2
+tbl_a  tbl_a_c3
+
diff --git 
a/regression-test/suites/information_schema_p0/test_information_schema_columns_missing_table.groovy
 
b/regression-test/suites/information_schema_p0/test_information_schema_columns_missing_table.groovy
new file mode 100644
index 00000000000..f5b1db15fc0
--- /dev/null
+++ 
b/regression-test/suites/information_schema_p0/test_information_schema_columns_missing_table.groovy
@@ -0,0 +1,74 @@
+// 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.
+
+// CIR-21356: information_schema.columns returns columns attributed to the
+// wrong table when a table disappears between the getTableNames and
+// describeTables RPCs, because describeTables does not append a tables_offset
+// for the missing table. FE.describeTables.skipTable simulates the missing
+// table by name. Skipping either table must not affect the IN query result
+// of the other table.
+suite("test_information_schema_columns_missing_table", "nonConcurrent") {
+    sql """drop database if exists 
test_information_schema_columns_missing_table"""
+    sql """create database test_information_schema_columns_missing_table"""
+    sql """
+        CREATE TABLE test_information_schema_columns_missing_table.tbl_a (
+            tbl_a_c0 INT, tbl_a_c1 INT, tbl_a_c2 INT, tbl_a_c3 INT
+        ) DUPLICATE KEY(tbl_a_c0) DISTRIBUTED BY HASH(tbl_a_c0) BUCKETS 1
+        PROPERTIES ("replication_num" = "1")
+    """
+    sql """
+        CREATE TABLE test_information_schema_columns_missing_table.tbl_b (
+            tbl_b_c0 INT, tbl_b_c1 INT, tbl_b_c2 INT
+        ) DUPLICATE KEY(tbl_b_c0) DISTRIBUTED BY HASH(tbl_b_c0) BUCKETS 1
+        PROPERTIES ("replication_num" = "1")
+    """
+
+    order_qt_baseline """
+        SELECT table_name, column_name
+        FROM information_schema.columns
+        WHERE table_schema = 'test_information_schema_columns_missing_table'
+        ORDER BY table_name, column_name
+    """
+
+    try {
+        // simulate tbl_a being dropped between getTableNames and 
describeTables
+        
GetDebugPoint().enableDebugPointForAllFEs('FE.describeTables.skipTable', 
[value: 'tbl_a'])
+        order_qt_skip_tbl_a """
+            SELECT table_name, column_name
+            FROM information_schema.columns
+            WHERE table_schema = 
'test_information_schema_columns_missing_table'
+              AND table_name IN ('tbl_b', 'awdadw')
+            ORDER BY table_name, column_name
+        """
+    } finally {
+        
GetDebugPoint().disableDebugPointForAllFEs('FE.describeTables.skipTable')
+    }
+
+    try {
+        // simulate tbl_b being dropped between getTableNames and 
describeTables
+        
GetDebugPoint().enableDebugPointForAllFEs('FE.describeTables.skipTable', 
[value: 'tbl_b'])
+        order_qt_skip_tbl_b """
+            SELECT table_name, column_name
+            FROM information_schema.columns
+            WHERE table_schema = 
'test_information_schema_columns_missing_table'
+              AND table_name IN ('tbl_a', 'awdadw')
+            ORDER BY table_name, column_name
+        """
+    } finally {
+        
GetDebugPoint().disableDebugPointForAllFEs('FE.describeTables.skipTable')
+    }
+}


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

Reply via email to