You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2025/06/12 10:47:42 UTC

(empire-db) branch master updated: EMPIREDB-456 DateUtils: limit timestamp nanos to 6 digits.

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

doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/master by this push:
     new e41492a5 EMPIREDB-456 DateUtils: limit timestamp nanos to 6 digits.
e41492a5 is described below

commit e41492a59d594fea11f430a51311c46675985f24
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Thu Jun 12 12:47:40 2025 +0200

    EMPIREDB-456
    DateUtils: limit timestamp nanos to 6 digits.
---
 .../java/org/apache/empire/commons/DateUtils.java  | 12 ++++++++--
 .../empire/db/validation/DBModelChecker.java       | 26 ++++++++++++++--------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java b/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
index c29cba96..237fb5d8 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/DateUtils.java
@@ -78,12 +78,20 @@ public class DateUtils
     }
 
     /**
-     * Returns a Timestamp for now
+     * Returns a Timestamp for now()
+     * The timstamp's nano seconds will be limited to 6 digits!
      * @return the Timestamp
      */
     public static Timestamp getTimestamp()
     {
-        return Timestamp.valueOf(LocalDateTime.now());
+        LocalDateTime ts = LocalDateTime.now();
+        // limit nano to 6 digits (999,999,000)
+        int nano = ts.getNano();
+        int remain = nano % 1000;
+        if (remain>0)
+            ts = LocalDateTime.of(ts.getYear(), ts.getMonth(), ts.getDayOfMonth(), ts.getHour(), ts.getMinute(), ts.getSecond(), nano - remain);
+        // convert to timestamp
+        return Timestamp.valueOf(ts);
     }
 
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java b/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java
index 4ef34aa1..a56a1233 100644
--- a/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java
+++ b/empire-db/src/main/java/org/apache/empire/db/validation/DBModelChecker.java
@@ -24,8 +24,10 @@ import java.util.List;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBMaterializedView;
 import org.apache.empire.db.DBRelation;
 import org.apache.empire.db.DBRelation.DBReference;
+import org.apache.empire.db.DBRowSet;
 import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 import org.apache.empire.db.DBView;
@@ -106,8 +108,9 @@ public class DBModelChecker
         DBTable remoteTable = remoteDb.getTable(table.getName()); // getTable(table.getName());
         if (remoteTable == null)
         {   // Check if it is a view instead
-            if (remoteDb.getView(table.getName())!=null)
-                handler.objectTypeMismatch(remoteTable, table.getName(), DBTable.class);
+            DBView remoteView = remoteDb.getView(table.getName()); 
+            if (remoteView!=null)
+                handler.objectTypeMismatch(remoteView, table.getName(), DBTable.class);
             else
                 handler.itemNotFound(table);
             return;
@@ -131,14 +134,19 @@ public class DBModelChecker
 
     protected void checkView(DBView view, DBModelErrorHandler handler)
     {
-        DBView remoteView = remoteDb.getView(view.getName());
+        DBRowSet remoteView = remoteDb.getView(view.getName());
         if (remoteView == null)
-        {   // Check if it is a table instead
-            if (remoteDb.getTable(view.getName())!=null)
-                handler.objectTypeMismatch(remoteView, view.getName(), DBView.class);
-            else
-                handler.itemNotFound(view);
-            return;
+        {   // Check if it's a table instead
+            DBTable remoteTable = remoteDb.getTable(view.getName());
+            if (remoteTable==null || !(view instanceof DBMaterializedView))
+            {   // not found or type mismatch
+                if (remoteTable!=null)
+                    handler.objectTypeMismatch(remoteTable, view.getName(), DBView.class);
+                else
+                    handler.itemNotFound(view);
+                return;
+            }
+            remoteView = remoteTable;
         }
         for (DBColumn column : view.getColumns())
         {