dybyte opened a new issue, #10352:
URL: https://github.com/apache/seatunnel/issues/10352

   ### Search before asking
   
   - [x] I had searched in the 
[feature](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22Feature%22)
 and found no similar feature requirement.
   
   
   ### Description
   
   Currently, the `PARSEDATETIME` and `TO_DATE` functions support only a 
limited set of formats.
   
   However, based on the current documentation and code, it is not clear which 
formats are officially supported. If unsupported formats are passed, the 
current implementation may not throw an exception and could return incorrect 
parsing results, potentially confusing users.
   
   To avoid ambiguity and ensure consistent mapping to `LocalDateTime` / 
`LocalDate` / `LocalTime`, we propose clarifying the supported formats as 
follows:
   
   **Supported formats:**
   
   - `yyyy-MM-dd HH:mm:ss` → `LocalDateTime`
   - `yyyy-MM-dd` → `LocalDate`
   - `HH:mm:ss` → `LocalTime`
   - `yyyy-MM-dd'T'HH:mm:ss` → `LocalDateTime`
   
   **Unsupported formats:**
   
   - Any other patterns, such as `yyyy-MM-dd HH:mm` or `yyyy-M-d H:m:s`, will 
throw an `UNSUPPORTED_OPERATION` exception.
   
   This approach prevents unexpected type inference.
   
   ```java
   public static Temporal parsedatetime(List<Object> args) {
           String str = (String) args.get(0);
           if (str == null) {
               return null;
           }
           String format = (String) args.get(1);
           if (format.contains("yy") && format.contains("mm")) {
               DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
               return LocalDateTime.parse(str, df);
           }
           if (format.contains("yy")) {
               DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
               return LocalDate.parse(str, df);
           }
           if (format.contains("mm")) {
               DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
               return LocalTime.parse(str, df);
           }
           throw new TransformException(
                   CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION,
                   String.format(
                           "Unknown pattern letter %s for function: %s",
                           format, ZetaSQLFunction.PARSEDATETIME));
       }
   
   ```
   
   ### Usage Scenario
   
   The format `yyyy-M-d H:m:s` is not supported and should throw an exception. 
Currently, it is parsed as `LocalDate`, silently causing incorrect results.
   
   ### Related issues
   
   #10328 
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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