Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Analytics by
retagged by

We are seeing some :db.type/instant values in Datomic come through as completely different dates in Datomic Analytics.

For instance

#inst "2020-01-01T00:00:00.000-00:00"

Shows up in Presto as

1970-01-19 06:17:16.800

Which suggests that at some point a unix timestamp is being misinterpreted.

(java.util.Date. (/ (.getTime #inst "2020-01-01T00:00:00.000-00:00") 1000))
;; => #inst "1970-01-19T06:17:16.800-00:00"

Example entity:

user=> (d/q '[:find (pull ?e [*]) :where [?e :accounting.fiscal-year/start-date ?y]] db)
[[{:db/id 17592186045894, :db/ensure [#:db{:id 17592186045471}], :accounting.fiscal-year/start-date #inst "2020-01-01T00:00:00.000-00:00", :accounting.fiscal-year/end-date #inst "2020-12-31T00:00:00.000-00:00", :accounting.fiscal-year/closed? false}]]

Field definition:

user=> (d/q '[:find (pull ?e [* {:db/valueType [:db/ident]}]) :where [?e :db/ident :accounting.fiscal-year/start-date]] db)
[[{:schema/boundary #:db{:id 17592186045443}, :db/unique #:db{:id 38}, :db/valueType #:db{:ident :db.type/instant}, :db.attr/preds [relvn.accounting.dbfn/date-only?], :schema/label "start date", :db/cardinality #:db{:id 35}, :db/doc "The starting date of a fiscal year.", :db/id 154, :schema/ident-type #:db{:id 17592186045420}, :db/ident :accounting.fiscal-year/start-date, :db/ensure [#:db{:id 17592186045424}], :schema/entity #:db{:id 17592186045470}}]]

In Presto:

presto:example_tenant__demo_company_14052021> select * from fiscal_year;
closing_description |       start_date        |        end_date         | closed_ |     db__id     
---------------------+-------------------------+-------------------------+---------+----------------
 NULL                | 1970-01-19 06:17:16.800 | 1970-01-19 15:02:52.800 | false   | 17592186045894 

1 Answer

0 votes
by

Arne,

Could you provide version numbers for all relevant parts?

...