LuciferYang opened a new issue, #9648: URL: https://github.com/apache/paimon/issues/9648
### Search before asking - [x] I searched in the [issues](https://github.com/apache/paimon/issues) and found nothing similar. ### Paimon version master, `475be566f` (2.1-SNAPSHOT). ### Compute Engine Any. `DateTimeUtils.parseDate` and `parseTime` back the STRING to DATE and STRING to TIME casts, reached from partition value parsing, column default values, filter literals pushed down from Flink, CDC ingestion and the Hive output format. ### Minimal reproduce step Cast a date string whose year does not fit in an `int`: ```java DateTimeUtils.parseDate("2147483648-01-01"); // java.lang.NumberFormatException: For input string: "2147483648" ``` Every other unparseable input returns null from these methods, including an out-of-range year: ```java DateTimeUtils.parseDate("99999-01-01"); // null, isIllegalDate rejects y > 9999 DateTimeUtils.parseDate("not-a-date"); // null ``` The guard in front of each `Integer.parseInt` only looks at the characters: ```java private static boolean isInteger(String s) { boolean isInt = s.length() > 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) < '0' || s.charAt(i) > '9') { isInt = false; break; } } return isInt; } ``` So a string of 11 digits passes and `Integer.parseInt` throws. Month, day and the time components behave the same way: `parseTime("2147483648:00:00")` throws as well. ### What doesn't meet your expectations? These methods return `Integer` and answer null for input they cannot parse; a value too large for an `int` is such an input. Instead a `NumberFormatException` escapes into the cast path, where `BinaryStringUtils.toDate` would otherwise turn the null into the `DateTimeException` that reports the bad value. ### Anything else? Fixing the guard changes the exception a caller sees for these inputs from `NumberFormatException` to the `DateTimeException` the cast raises for any other unparseable string. One place behaves differently rather than just reporting differently: the Hive `PaimonTimeObjectInspector.convert` returns the `Integer` as is, so a TIME column with such a value writes NULL instead of failing, which is what already happens for other invalid times like `"25:00:00"`. ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
