This is an automated email from the ASF dual-hosted git repository.

xuzifu666 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 9f575b39a0 [CALCITE-7370] Trailing dot is not removed when normalizing 
timestamp strings
9f575b39a0 is described below

commit 9f575b39a0a57ee643f78210eff7edd208ffe62f
Author: Dongsheng He <[email protected]>
AuthorDate: Tue Jan 13 17:53:59 2026 +0800

    [CALCITE-7370] Trailing dot is not removed when normalizing timestamp 
strings
---
 core/src/main/java/org/apache/calcite/util/TimestampString.java | 4 ++++
 core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java   | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/core/src/main/java/org/apache/calcite/util/TimestampString.java 
b/core/src/main/java/org/apache/calcite/util/TimestampString.java
index c6c7c18ade..a4b16b2896 100644
--- a/core/src/main/java/org/apache/calcite/util/TimestampString.java
+++ b/core/src/main/java/org/apache/calcite/util/TimestampString.java
@@ -126,6 +126,10 @@ private static String normalize(String v) {
       while (v.endsWith("0")) {
         v = v.substring(0, v.length() - 1);
       }
+      // Remove trailing dot
+      if (v.endsWith(".")) {
+        v = v.substring(0, v.length() - 1);
+      }
     }
     checkArgument(PATTERN.matcher(v).matches(), v);
     return v;
diff --git a/core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java 
b/core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java
index 4b714e8632..7653d5370c 100644
--- a/core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java
+++ b/core/src/test/java/org/apache/calcite/rex/RexBuilderTest.java
@@ -357,6 +357,10 @@ private static class MySqlTypeFactoryImpl extends 
SqlTypeFactoryImpl {
     final TimestampString ts10 = TimestampString.fromCalendarFields(c);
     assertThat(ts10, hasToString("1969-02-26 19:06:00.987"));
     assertThat(ts10.getMillisSinceEpoch(), is(c.getTimeInMillis()));
+
+    // TimestampString with all zeros fraction
+    final TimestampString ts11 = new TimestampString("2016-02-26 
19:06:00.000");
+    assertThat(ts11, hasToString("2016-02-26 19:06:00"));
   }
 
   @Test void testTimeString() {

Reply via email to