You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "yuxiqian (via GitHub)" <gi...@apache.org> on 2026/05/24 06:34:19 UTC

Re: [PR] [FLINK-39492][starrocks] Fix microsecond precision loss for TIMESTAMP types in StarRocks sink [flink-cdc]

yuxiqian commented on code in PR #4404:
URL: https://github.com/apache/flink-cdc/pull/4404#discussion_r3294005294


##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-starrocks/src/main/java/org/apache/flink/cdc/connectors/starrocks/sink/StarRocksUtils.java:
##########
@@ -137,6 +137,31 @@ public static void toStarRocksDataType(
     private static final DateTimeFormatter DATETIME_FORMATTER =
             DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
+    private static final DateTimeFormatter[] DATETIME_FORMATTERS = new DateTimeFormatter[10];
+
+    private static DateTimeFormatter datetimeFormatter(int precision) {
+        if (precision <= 0) {
+            return DATETIME_FORMATTER;
+        }
+        if (precision < DATETIME_FORMATTERS.length) {

Review Comment:
   The maximal precision for temporal types is 9. We may add a precondition guard here, and remove the non-caching branch.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org