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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new a215a63b50b branch-3.0: [fix](external catalog) Persisting the 
External Catalog comment field #46946 (#47270)
a215a63b50b is described below

commit a215a63b50b571494e30000dce7283d648dd4335
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Feb 25 19:05:19 2025 +0800

    branch-3.0: [fix](external catalog) Persisting the External Catalog comment 
field #46946 (#47270)
    
    Cherry-picked from #46946
    
    Co-authored-by: zy-kkk <zhongy...@gmail.com>
---
 .../apache/doris/datasource/ExternalCatalog.java   |  4 ++-
 .../doris/datasource/ExternalCatalogTest.java      | 33 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
index 7a81076773b..d315373eca0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
@@ -139,6 +139,9 @@ public abstract class ExternalCatalog
     // <db name, table name> to tableAutoAnalyzePolicy
     @SerializedName(value = "taap")
     protected Map<Pair<String, String>, String> tableAutoAnalyzePolicy = 
Maps.newHashMap();
+    @SerializedName(value = "comment")
+    private String comment;
+
     // db name does not contains "default_cluster"
     protected Map<String, Long> dbNameToId = Maps.newConcurrentMap();
     private boolean objectCreated = false;
@@ -147,7 +150,6 @@ public abstract class ExternalCatalog
     protected TransactionManager transactionManager;
 
     private ExternalSchemaCache schemaCache;
-    private String comment;
     // A cached and being converted properties for external catalog.
     // generated from catalog properties.
     private byte[] propLock = new byte[0];
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/ExternalCatalogTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/ExternalCatalogTest.java
index f8e72c366b5..67d1e2d7ab4 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/ExternalCatalogTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/ExternalCatalogTest.java
@@ -276,4 +276,37 @@ public class ExternalCatalogTest extends TestWithFeService 
{
         dis.close();
         file.delete();
     }
+
+    @Test
+    public void testSerializationWithComment() throws Exception {
+        MetaContext metaContext = new MetaContext();
+        metaContext.setMetaVersion(FeMetaVersion.VERSION_CURRENT);
+        metaContext.setThreadLocalInfo();
+
+        // 1. Write objects to file
+        File file = new File("./external_catalog_with_comment_test.dat");
+        file.createNewFile();
+        DataOutputStream dos = new 
DataOutputStream(Files.newOutputStream(file.toPath()));
+
+        TestExternalCatalog ctl = (TestExternalCatalog) 
mgr.getCatalog("test1");
+        String testComment = "This is a test comment for serialization";
+        ctl.setComment(testComment); // Set a custom comment value
+        ctl.write(dos);
+        dos.flush();
+        dos.close();
+
+        // 2. Read objects from file
+        DataInputStream dis = new 
DataInputStream(Files.newInputStream(file.toPath()));
+
+        TestExternalCatalog ctl2 = (TestExternalCatalog) 
ExternalCatalog.read(dis);
+        Configuration conf = ctl2.getConfiguration();
+        Assertions.assertNotNull(conf);
+
+        // Verify the comment is properly serialized and deserialized
+        Assertions.assertEquals(testComment, ctl2.getComment());
+
+        // 3. delete files
+        dis.close();
+        file.delete();
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to