Fork me on GitHub
#xtdb
<
2023-09-02
>
Tomato04:09:27

Hello XTDB team! I'm exploring XTDB 2.0 and am encountering some challenges with Datalog.

Tomato04:09:38

Can I pass a Datetime value to the :for-valid-time [:at ] clause in Datalog? Below is an example:

(xt/q node ['{:find [title xt/id]
              :where [($ :todos [{:title title
                                  :xt/id xt/id}]
                         {:for-valid-time [:at #inst "2023-09-03"]})]}])
I'd like to use either an Instant or ZonedDateTime value instead:
(xt/q node ['{:find [title]
              :in [dt]
              :where [($ :todos [{:title title}]
                         {:for-valid-time [:at dt]})]}
            (java.time.Instant/now)])
However, this approach seems to be incorrect. The exception I encounter is:
java.lang.NullPointerException: Cannot invoke "xtdb.vector.IIndirectVector.getVecter()" becuase "col" is null

refset12:09:15

Hey @U01CNN12HNY I'm not sure on exactly what should be working here currently - but do you get the same result with a more precise #inst literal? e.g. #inst "2023-09-02T16:00:00"? This could equally be an issue with parameterising the :at value (in which case you could work around it with quoting / constructing the query as data)

Tomato12:09:53

hi thanks for answering. I've tried parameterizing the Datetime, so I can't use parameterization with :in. Are you suggesting that I construct the query as data? Is that correct?

refset13:09:45

> Are you suggesting that I construct the query as data? Is that correct? yes, that should unblock you for now, at least

refset13:09:10

but I'll check with the team about the expected behaviour next week - and potentially open an issue

Tomato16:09:54

thanks a lot!

πŸ‘Œ 2
refset12:09:06

hey again @U01CNN12HNY we just opened an issue to track the resolution on this https://github.com/xtdb/xtdb/issues/2754 - thanks again for flagging it πŸ™

πŸ‘ 2
Tomato14:09:04

wow! good to know! thank you!

☺️ 2