platinumhamburg commented on code in PR #3621:
URL: https://github.com/apache/fluss/pull/3621#discussion_r3564475150


##########
fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java:
##########
@@ -242,6 +252,154 @@ private static void checkSystemColumns(RowType schema) {
         }
     }
 
+    private static void checkRowTTL(Configuration tableConf, Schema schema, 
boolean hasPrimaryKey) {
+        Optional<Duration> rowTTL = 
tableConf.getOptional(ConfigOptions.TABLE_ROW_TTL);
+        Optional<String> timeColumn =
+                tableConf.getOptional(ConfigOptions.TABLE_ROW_TTL_TIME_COLUMN);
+        Optional<String> timeColumnId =
+                
Optional.ofNullable(tableConf.toMap().get(TableConfig.ROW_TTL_TIME_COLUMN_ID_KEY));
+
+        if (timeColumn.isPresent() && !rowTTL.isPresent()) {
+            throw new InvalidConfigException(
+                    String.format(
+                            "'%s' requires '%s' to be set.",
+                            ConfigOptions.TABLE_ROW_TTL_TIME_COLUMN.key(),
+                            ConfigOptions.TABLE_ROW_TTL.key()));
+        }
+
+        if (timeColumnId.isPresent() && !timeColumn.isPresent()) {
+            throw new InvalidConfigException(
+                    String.format(
+                            "'%s' requires '%s' to be set.",
+                            TableConfig.ROW_TTL_TIME_COLUMN_ID_KEY,
+                            ConfigOptions.TABLE_ROW_TTL_TIME_COLUMN.key()));
+        }
+
+        if (!rowTTL.isPresent()) {
+            return;
+        }
+
+        if (!hasPrimaryKey) {
+            throw new InvalidTableException(
+                    String.format(
+                            "'%s' is only supported for primary key tables.",
+                            ConfigOptions.TABLE_ROW_TTL.key()));
+        }
+
+        validateRowTTLDuration(rowTTL.get());
+
+        if (timeColumn.isPresent()) {
+            Schema.Column column = getRowTTLTimeColumn(schema, 
timeColumn.get());
+            validateRowTTLTimeColumnType(column.getDataType());
+            if (timeColumnId.isPresent()) {
+                validateRowTTLTimeColumnId(timeColumnId.get(), 
column.getColumnId());
+            }
+        }

Review Comment:
   Issue updated.



-- 
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]

Reply via email to