dalelane commented on code in PR #28828:
URL: https://github.com/apache/flink/pull/28828#discussion_r3661514477


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/utils/ValueDataTypeConverter.java:
##########
@@ -217,7 +217,7 @@ private static int fractionalSecondPrecision(int nanos) {
         return String.format("%09d", nanos).replaceAll("0+$", "").length();
     }
 
-    private static int yearPrecision(int years) {
+    private static int yearPrecision(long years) {
         return String.valueOf(years).length();

Review Comment:
   not introduced in this PR, but I noticed it while reading - relying on a 
string-length to determine precision seems risky. This would return the wrong 
value for a negative number, because it'll count the `-` sign in the string 
length. 
   
   For example, someone using the Table API to do something like 
`lit(Period.ofYears(-1000))` will end up hitting a validation exception
   
   As I say - not introduced in this change, but wrapping the `years` value in 
a Math.abs would be enough to fix it



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