mchades commented on code in PR #4343:
URL: https://github.com/apache/gravitino/pull/4343#discussion_r1705105899
##########
catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java:
##########
@@ -164,6 +168,37 @@ protected String generateCreateTableSql(
return result;
}
+ private Map<String, String> appendNecessaryProperties(Map<String, String>
properties) {
+ Map<String, String> resultMap;
+ if (properties == null) {
+ resultMap = new HashMap<>();
+ } else {
+ resultMap = new HashMap<>(properties);
+ }
+
+ // If the backend server is less than 3, we need to set the property
'replication_num'
+ // to 1 explicitly.
+ if (!properties.containsKey(REPLICATION_FACTOR)) {
+ // Try to check the number of backend servers.
+ String query = "select count(*) from information_schema.backends where
Alive = 'true'";
+
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet = statement.executeQuery(query)) {
+ while (resultSet.next()) {
+ int backendCount = resultSet.getInt(1);
+ if (backendCount < 3) {
+ resultMap.put(REPLICATION_FACTOR,
String.valueOf(DEFAULT_REPLICATION_FACTOR));
Review Comment:
suggest use `propertiesMetadata.getOrDefault` to get the default value
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]