Fork me on GitHub
#xtdb
<
2023-02-14
>
refset11:02:16

Is anyone here going to the https://2023.clojure-conj.org/? XTDB will be present 🙂

4
🤞 2
👍 2
richiardiandrea18:02:41

Probably remote 😉

James Pratt13:02:38

is it expected that the second query here returns an empty set?

(ns predicate
  (:require [xtdb.api :as xt]))

(def node (xt/start-node {}))

(defn easy-ingest
  [node docs]
  (xt/submit-tx node
                (vec (for [doc docs]
                       [::xt/put doc])))
  (xt/sync node))

(def data
  [{:xt/id :commodity/Pu
    :density 19.816}
   ])

(easy-ingest node data)

(xt/q (xt/db node)
      '{:find [element]
        :where [[element :density density]
                [(> density 19.0)]]})
;; => #{[:commodity/Pu]}

(xt/q (xt/db node)
      '{:find [element]
        :where [[element :density density]
                [(> density 19)]]})
;; => #{}

(> 19.816 19)
;; => true

(> 19.816 19.0)
;; => true

James Pratt13:02:04

ie. this query returns an empty set:

(xt/q (xt/db node)
      '{:find [element]
        :where [[element :density density]
                [(> density 19)]]})
;; => #{}

refset15:02:55

Hey @U03DBC3BGAV this is expected behaviour, and it's because the predicate pushdown of > operates on the binary representation across two different types (with distinct byte prefixes). This is contrast to Clojure's semantics that will attempt to coerce and compare across numeric types more intuitively. To work around it you can either harmonise the types before storing (i.e. coerce the ints/longs to floats), or you can use clojure.core/> instead of > - but this latter option won't benefit from predicate pushdown (against the sorted indexes) and will result in additional scanning

James Pratt17:02:09

thanks for the clarification.

🙏 2
richiardiandrea18:02:34

Hi all, kind of misspoke during the meetup (which was recorded, I wish I could transact the following with valid-time=now 🙂). About our parent-children relationship: we only need to "touch" the parent when the children change, not the other way around. That way we are always sure that hydrating using valid time is consistent between the two. Changing the parent does not involve changing children because querying by parent valid time will still include previous children changes I hope it makes sense :)

🙏 2
refset19:02:29

^ for full context, https://discuss.xtdb.com/t/video-virtual-meetup-3-recording-history-apis/147 the replay from today's meetup - thanks again to everyone who joined and shared in the discussion 🌞

❤️ 2