diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java index 00f616e1bb73f..764672e7520ae 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/jdbc/PostgresSchemaResolver.java @@ -28,6 +28,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -67,18 +68,20 @@ public List convertToSRTable(ResultSet columnSet) throws SQLException { @Override public Table getTable(long id, String name, List schema, String dbName, String catalogName, Map properties) throws DdlException { - properties.putIfAbsent(JDBCTable.ORIGINAL_DBNAME, dbName); - properties.putIfAbsent(JDBCTable.ORIGINAL_TABLENAME, name); - return new JDBCTable(id, "\"" + dbName + "\"" + "." + "\"" + name + "\"", schema, "", catalogName, properties); + Map newProp = new HashMap<>(properties); + newProp.putIfAbsent(JDBCTable.ORIGINAL_DBNAME, dbName); + newProp.putIfAbsent(JDBCTable.ORIGINAL_TABLENAME, name); + return new JDBCTable(id, "\"" + dbName + "\"" + "." + "\"" + name + "\"", schema, "", catalogName, newProp); } @Override public Table getTable(long id, String name, List schema, List partitionColumns, String dbName, String catalogName, Map properties) throws DdlException { - properties.putIfAbsent(JDBCTable.ORIGINAL_DBNAME, dbName); - properties.putIfAbsent(JDBCTable.ORIGINAL_TABLENAME, name); + Map newProp = new HashMap<>(properties); + newProp.putIfAbsent(JDBCTable.ORIGINAL_DBNAME, dbName); + newProp.putIfAbsent(JDBCTable.ORIGINAL_TABLENAME, name); return new JDBCTable(id, "\"" + dbName + "\"" + "." + "\"" + name + "\"", schema, partitionColumns, - "", catalogName, properties); + "", catalogName, newProp); } @Override diff --git a/fe/fe-core/src/test/java/com/starrocks/connector/jdbc/PostgresSchemaResolverTest.java b/fe/fe-core/src/test/java/com/starrocks/connector/jdbc/PostgresSchemaResolverTest.java index 2286676011b41..8a270fc55e244 100644 --- a/fe/fe-core/src/test/java/com/starrocks/connector/jdbc/PostgresSchemaResolverTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/connector/jdbc/PostgresSchemaResolverTest.java @@ -17,6 +17,7 @@ import com.google.common.collect.Lists; import com.mockrunner.mock.jdbc.MockResultSet; +import com.starrocks.catalog.Column; import com.starrocks.catalog.Database; import com.starrocks.catalog.JDBCResource; import com.starrocks.catalog.JDBCTable; @@ -29,6 +30,7 @@ import java.sql.Connection; import java.sql.DriverManager; +import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.Arrays; @@ -168,6 +170,13 @@ public void testGetTable() throws SQLException { Assert.assertTrue(table instanceof JDBCTable); Assert.assertEquals("catalog.test.tbl1", table.getUUID()); Assert.assertEquals("\"test\".\"tbl1\"", table.getName()); + Assert.assertNull(properties.get(JDBCTable.ORIGINAL_TABLENAME)); + PostgresSchemaResolver postgresSchemaResolver = new PostgresSchemaResolver(); + ResultSet columnSet = postgresSchemaResolver.getColumns(connection, "test", "tbl1"); + List fullSchema = postgresSchemaResolver.convertToSRTable(columnSet); + Table table1 = postgresSchemaResolver.getTable(1, "tbl1", fullSchema, "test", "catalog", properties); + Assert.assertTrue(table1 instanceof JDBCTable); + Assert.assertNull(properties.get(JDBCTable.ORIGINAL_TABLENAME)); } catch (Exception e) { System.out.println(e.getMessage()); Assert.fail();