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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 5140ae86c44 [fix](schema) Table column order is changed if add a 
column and do truncate (#24981)
5140ae86c44 is described below

commit 5140ae86c441715ebb86ce46fc9d44f8e0005c04
Author: meiyi <[email protected]>
AuthorDate: Wed Sep 27 20:59:11 2023 +0800

    [fix](schema) Table column order is changed if add a column and do truncate 
(#24981)
---
 .../apache/doris/datasource/InternalCatalog.java   | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index 979bdf66929..46cbb2122c9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -1595,17 +1595,19 @@ public class InternalCatalog implements 
CatalogIf<Database> {
 
                         List<Column> oldSchema = 
indexIdToMeta.get(indexId).getSchema();
                         List<Column> newSchema = entry.getValue().getSchema();
-                        oldSchema.sort((Column a, Column b) -> a.getUniqueId() 
- b.getUniqueId());
-                        newSchema.sort((Column a, Column b) -> a.getUniqueId() 
- b.getUniqueId());
                         if (oldSchema.size() != newSchema.size()) {
                             LOG.warn("schema column size diff, old schema {}, 
new schema {}", oldSchema, newSchema);
                             metaChanged = true;
                             break;
                         } else {
-                            for (int i = 0; i < oldSchema.size(); ++i) {
-                                if 
(!oldSchema.get(i).equals(newSchema.get(i))) {
-                                    LOG.warn("schema diff, old schema {}, new 
schema {}",
-                                            oldSchema.get(i), 
newSchema.get(i));
+                            List<Column> oldSchemaCopy = 
Lists.newArrayList(oldSchema);
+                            List<Column> newSchemaCopy = 
Lists.newArrayList(newSchema);
+                            oldSchemaCopy.sort((Column a, Column b) -> 
a.getUniqueId() - b.getUniqueId());
+                            newSchemaCopy.sort((Column a, Column b) -> 
a.getUniqueId() - b.getUniqueId());
+                            for (int i = 0; i < oldSchemaCopy.size(); ++i) {
+                                if 
(!oldSchemaCopy.get(i).equals(newSchemaCopy.get(i))) {
+                                    LOG.warn("schema diff, old schema {}, new 
schema {}", oldSchemaCopy.get(i),
+                                            newSchemaCopy.get(i));
                                     metaChanged = true;
                                     break;
                                 }
@@ -2969,15 +2971,18 @@ public class InternalCatalog implements 
CatalogIf<Database> {
 
                 List<Column> oldSchema = copiedTbl.getFullSchema();
                 List<Column> newSchema = olapTable.getFullSchema();
-                oldSchema.sort((Column a, Column b) -> a.getUniqueId() - 
b.getUniqueId());
-                newSchema.sort((Column a, Column b) -> a.getUniqueId() - 
b.getUniqueId());
                 if (oldSchema.size() != newSchema.size()) {
                     LOG.warn("schema column size diff, old schema {}, new 
schema {}", oldSchema, newSchema);
                     metaChanged = true;
                 } else {
-                    for (int i = 0; i < oldSchema.size(); ++i) {
-                        if (!oldSchema.get(i).equals(newSchema.get(i))) {
-                            LOG.warn("schema diff, old schema {}, new schema 
{}", oldSchema.get(i), newSchema.get(i));
+                    List<Column> oldSchemaCopy = Lists.newArrayList(oldSchema);
+                    List<Column> newSchemaCopy = Lists.newArrayList(newSchema);
+                    oldSchemaCopy.sort((Column a, Column b) -> a.getUniqueId() 
- b.getUniqueId());
+                    newSchemaCopy.sort((Column a, Column b) -> a.getUniqueId() 
- b.getUniqueId());
+                    for (int i = 0; i < oldSchemaCopy.size(); ++i) {
+                        if 
(!oldSchemaCopy.get(i).equals(newSchemaCopy.get(i))) {
+                            LOG.warn("schema diff, old schema {}, new schema 
{}", oldSchemaCopy.get(i),
+                                    newSchemaCopy.get(i));
                             metaChanged = true;
                             break;
                         }


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

Reply via email to