This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-05
Channels
- # announcements (12)
- # babashka (29)
- # bangalore-clj (3)
- # beginners (153)
- # calva (2)
- # chlorine-clover (46)
- # cider (11)
- # clj-kondo (21)
- # cljfx (20)
- # cljs-dev (3)
- # clojure (393)
- # clojure-australia (2)
- # clojure-europe (15)
- # clojure-spec (40)
- # clojure-uk (1)
- # clojurescript (3)
- # community-development (1)
- # conjure (2)
- # cursive (1)
- # data-oriented-programming (1)
- # datomic (7)
- # defnpodcast (2)
- # docs (2)
- # figwheel-main (5)
- # fulcro (52)
- # graalvm (2)
- # inf-clojure (21)
- # malli (10)
- # meander (6)
- # mid-cities-meetup (13)
- # nrepl (1)
- # off-topic (24)
- # other-languages (1)
- # pathom (3)
- # polylith (18)
- # re-frame (6)
- # reitit (11)
- # ring-swagger (2)
- # shadow-cljs (56)
- # specter (1)
- # xtdb (7)
Is it possible/reasonable to use range predicates on mixed-type fields? Mixing strings/longs causes type errors during the queries, but I don’t like wrapping it in some safe-gte
function that has a try/catch because I think crux optimizes ranges and I’d prefer to keep that.
Sadly not, since the encoding for each value is prefixed with a type id, which means the internal sorting can only be per-type. Are you consciously wanting to avoid enforcing the type of each attribute before submitting?
Yeah, the data I’m working with has a pretty loose schema. I’m fine enforcing the type of the attribute on query time though - as in, I query for a range of ints, I only get back ints. I think that would work with what you said about the index?
I dunno if that’s reasonable behavior for crux to have in general though. The classcastexception is jarring but at least it’s exact.
That's fair, we're not completely satisfied with how the range predicates work today, for instance there's this open issue: https://github.com/juxt/crux/issues/1298
You can however explicitly use the actual Clojure comparison functions by using the fully-qualified names (e.g. clojure.core/>
) and this will workaround all of Crux's Datalog range query logic, at the cost of potentially not using the indexes efficiently.
> I’m fine enforcing the type of the attribute on query time though - as in, I query for a range of ints, I only get back ints. I think that would work with what you said about the index?
I think that will be okay, yep, just make sure to write some decent tests otherwise I know from experience that it can easily get confusing 🙂
Yeah that’s an interesting one, especially the Big* because those are a pain to promote into. Is the expected index bump because the idea is to add a type/subtype column so that all number types get grouped together? Then you’d just need a suitable comparator for all those number types.