davidzollo commented on PR #10360:
URL: https://github.com/apache/seatunnel/pull/10360#issuecomment-3796509819
Good job.
I found there is one issue you can do it better ^_^
### Performance Bottleneck
**Location**:
`seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/DateTimeFunction.java`
(Line ~646)
**Description**: The code calls
`DateTimeFormatter.ofPattern(dateTimeFormat.getPattern())` inside the
`parsedatetime` method. Since this UDF executes **per row**, compiling the
pattern every time is extremely inefficient for high-throughput scenarios.
**Recommendation**:
Cache the `DateTimeFormatter` instance within the `ZetaDateTimeFormat` enum.
`DateTimeFormatter` is thread-safe and should be created only once.
**Suggested Change**:
Refactor `ZetaDateTimeFormat` to initialize the formatter in its constructor:
```java
public enum ZetaDateTimeFormat {
// ...
private final DateTimeFormatter formatter;
ZetaDateTimeFormat(String pattern, FormatType type) {
this.pattern = pattern;
this.type = type;
this.formatter = DateTimeFormatter.ofPattern(pattern); // Initialize
once
}
public DateTimeFormatter getFormatter() { return formatter; }
}
```
Then use `dateTimeFormat.getFormatter()` in the function.
By the way, there is a smaill Issue: Whitelist Too Strict
**Description**: The current whitelist misses common formats like compact
dates (`yyyyMMdd`) or slash separators (`yyyy/MM/dd`).
**Recommendation**: Expand the whitelist to include these common variations
to reduce migration friction for users.
--
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]