datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
danieroux 2021-04-28T09:38:45.417100Z

What is the simplest way to have cronjobs functionality on Datomic Cloud?

tatut 2021-04-28T09:40:39.417200Z

idk about simplest, but we’ve used cloudwatch cron events to trigger an ion lambda

danieroux 2021-04-28T10:05:58.417400Z

Ah, did not know cloudwatch had that. And, of course, would prefer something not-in-AWS.

tatut 2021-04-28T10:30:00.417600Z

datomic cloud is always in aws

tatut 2021-04-28T10:30:50.417800Z

it is easier to control the cron job than to build some threads that are run on all nodes of the compute group, but ymmv

danieroux 2021-04-28T11:56:49.418Z

I am definitely not syncing threads across all nodes, that seems like an invitation to screw up! I’ll give in to cloudwatch and triggering ions, thank you

2021-04-28T15:14:02.418900Z

hmm. something still a little wonky even within a valid range :thinking_face:

2021-04-28T15:43:10.420300Z

Hello. How I can get it work? I got Assert failed: All clauses in 'or' must use same set of vars, had [#{?email ?e} #{?phone ?e}]

[:find ?e
 :in $ ?email ?phone ?id
 :where
 (or [?e :worker/email ?email]
     [?e :worker/phone ?phone])
 (not [?e :worker/id ?id])]

2021-04-28T15:44:55.421300Z

While docs example uses also different set but it works

[:find (count ?artist) .
 :where (or [?artist :artist/type :artist.type/group]
            (and [?artist :artist/type :artist.type/person]
                 [?artist :artist/gender :artist.gender/female]))]

favila 2021-04-28T16:00:12.421800Z

nm, didn’t read carefully

2021-04-28T16:00:39.422400Z

This way seems to be working

[:find ?e
 :in $ ?email ?phone ?id
 :where
 (or-join [?e ?email ?phone]
          [?e :worker/email ?email]
          [?e :worker/phone ?phone])
 (not [?e :worker/id ?id])]

2021-04-28T16:00:53.422600Z

As much as I tested it

favila 2021-04-28T16:01:12.422800Z

yes that is correct.

2021-04-28T16:01:57.423Z

The reason was cause of input parameters but not values?

favila 2021-04-28T16:03:26.423200Z

All “branches/implemenations” of a rule must have the same bindings. If you don’t specify bindings the parser infers them from whatever bindings it sees in each branch. If they don’t match, you get that warning

2021-04-28T16:03:28.423400Z

If I set values in place of input arguments it works with or also

favila 2021-04-28T16:04:22.423600Z

or-join (and all -join variants) say explicitly what bindings there are. implementations that don’t use a binding will just not unify against it, which is what you want here

favila 2021-04-28T16:04:54.423800Z

you want one implementation to unify against email and ignore phone, and the other to do the opposite

favila 2021-04-28T16:05:13.424Z

and the results from both are set-unioned

2021-04-28T16:06:10.424200Z

Thanks, seems that I meeting this case regulary and forget the rules every time after )

favila 2021-04-28T16:06:58.424500Z

It helps me to think of or* and and* as just syntax sugar for rules, and think about the rule I would write

2021-04-28T16:08:07.424700Z

Thanks again, I'l try to rethink my mental model of it

favila 2021-04-28T16:08:40.424900Z

e.g. this would be [[(worker-phone-or-email ?e ?phone ?email) [?e :worker/email ?email]]…] Saying (worker-phone-or-email ?e ?phone) for one impl and (worker-phone-or-email ?e ?email) for the other would be more obviously wrong

2021-04-28T16:13:01.425200Z

maybe I'l just rewrite query to use direct values instead of input parameters, cause I still dont understand this -join magic perfectly

2021-04-28T16:13:51.425400Z

Working with Clojure is much understandable than with datomic )