snuyanzin commented on code in PR #27845:
URL: https://github.com/apache/flink/pull/27845#discussion_r3011503885


##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/utils/MaterializedTableUtils.java:
##########
@@ -68,29 +71,110 @@ public class MaterializedTableUtils {
 
     public static IntervalFreshness getMaterializedTableFreshness(
             SqlIntervalLiteral sqlIntervalLiteral) {
-        if (sqlIntervalLiteral.signum() < 0) {
-            throw new ValidationException(
-                    "Materialized table freshness doesn't support negative 
value.");
+        return new IntervalFreshness(getFreshnessInterval(sqlIntervalLiteral));
+    }
+
+    private static Interval getFreshnessInterval(SqlIntervalLiteral 
sqlIntervalLiteral) {
+        final IntervalValue intervalValue = 
sqlIntervalLiteral.getValueAs(IntervalValue.class);
+        final SqlTypeName typeName = 
intervalValue.getIntervalQualifier().typeName();
+
+        if (isDateTimeInterval(typeName)) {

Review Comment:
   it is enough 
   if you look at implementation
   ```java
    private static Interval getDayTimeInterval(
               final IntervalValue intervalValue,
               final SqlTypeName typeName,
               final BigDecimal interval,
               final String intervalDescription) {
           final int intervalInt = (int) (interval.longValue() / 1000);
           switch (typeName) {
               case INTERVAL_DAY:
                   final int amountOfDays = intervalInt / 60 / 60 / 24;
                   if 
(intervalValue.getIntervalQualifier().timeUnitRange.startUnit
                           == org.apache.calcite.avatica.util.TimeUnit.WEEK) {
                       return Interval.of(amountOfDays / 7, TimeUnit.WEEK);
                   }
                   return Interval.of(amountOfDays, TimeUnit.DAY);
   ...
   ```



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