Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,37 @@ public void testSerialization() throws Exception {
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();
}
}
Loading