This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-14
Channels
- # babashka (43)
- # beginners (47)
- # biff (1)
- # calva (16)
- # cider (7)
- # clerk (6)
- # clj-kondo (39)
- # cljdoc (49)
- # clojure (29)
- # clojure-brasil (1)
- # clojure-europe (93)
- # clojure-losangeles (1)
- # clojure-norway (34)
- # conjure (7)
- # datalevin (8)
- # events (1)
- # gratitude (3)
- # honeysql (6)
- # hyperfiddle (2)
- # introduce-yourself (1)
- # javascript (1)
- # jobs-discuss (9)
- # lsp (3)
- # malli (10)
- # off-topic (8)
- # pedestal (3)
- # rewrite-clj (2)
- # shadow-cljs (17)
- # sql (33)
- # vim (1)
- # xtdb (31)
How do you handle schema changes when working with XTDB? Right now if my data's shape change, I connect to the prod Xtdb Node with a local repl and update the resources as necessary.
Hi @U0105D1EL4B, In XTDB there is no explicit notion of schema change - are you referring to using :xt/put
to change attribute names or types? Have you got an example of what you are trying to achieve so I can better help?
I use schemas for my REST API, with reitit coercion and malli validation. If i want to change my schema, for example the name of an attribute or add a new attribute that's not optional etc, I need the data in the db to reflect the new schema
There is no ALTER TABLE
type statement that will rewrite your data automatically. You would need to use :xt/put
to overwrite your data with the desired structure. For example, you could use a transaction function to query for affected data and emit the desired :xt/put
ops.
Be aware that transaction sizes are limited to main memory, so you might not want to rewrite millions of documents in a single transaction.
Any ideas when you could update dependencies in XTDB libraries? Our automated cve-check failed due to an old com.google.guava
version (31.1, https://ossindex.sonatype.org/vulnerability/CVE-2023-2976?component-type=maven&component-name=com.google.guava%2Fguava&utm_source=dependency-check&utm_medium=integration&utm_content=8.2.1). Latest library versions 1.23.2 do not solve this. It's a transient dependency:
xtdb-google-cloud-storage
google-cloud-nio
guava
Thanks for the report @U0267SNCPEY, I will take a look at bumping the dependency. Have you been able to override the dependency version (by including the desired version explicitly in your lein project.clj
or clj deps.edn
)?
I have created an issue here: https://github.com/xtdb/xtdb/issues/2564
Not yet, it was caught by deployment and I temporarily suppressed the cve issue in order to deploy.
And we could override that particular version yes, but we have another shadowed guava dependency which is a real problem
hey yall, let me know if this is the right place for this question but Im writing this pull query: (pull m [* {:workout-movement/_movement [{:workout-movement/workout [*]}]}])
and I want to filter the :workout-movement/workout
by an attribute on the :workout
entity. Im struggling to do so… I either get no records back (where I want just the root record m
) or I get workouts
that I am trying to filter. yall have any recommendations for how to do this or where to explore?
Hey @U0CKDV6DB 👋
Pull is more of a projection tool - once you've found the documents you're interested in, pull will get you the data in the shape you need it.
I'd use triples in the :where
clause to filter the data down first - e.g. (guessing at your data model):
{:find [(pull m [* {:workout-movement/_movement [{:workout-movement/workout [*]}]}])]
:in [filter-val]
:where [[wm :workout-movement/movement m]
[wm :workout-movement/workout w]
[w :workout/attr-to-filter filter-val]]}
yeah, for a query like this, the [w :workout/attr-to-filter filter-val]
isnt filtering out the workouts I’d expect
(q db
'{:find [(pull m [* {:workout-movement/_movement [{:workout-movement/workout [*]}]}])]
:in [user]
:where [[m :movement/name "muscle up"]
[wm :workout-movement/movement m]
[wm :workout-movement/workout w]
[w :workout/user user]
]}
user-a)
I’ve conceded to just doing this
(let [m (xt/entity db (parse-uuid (:id path-params)))
workouts (biff/q db '{:find (pull w [*])
:in [[movement user]]
:where [[w :workout/name]
(or [w :workout/user user]
(and [w :workout/name]
(not [w :workout/user])))
[wm :workout-movement/workout w]
[wm :workout-movement/movement movement]]}
[(parse-uuid (:id path-params)) (:uid session)])])
oh, of course, sorry, yes - because the pull ignores the filter and starts again, traversing the graph from the movement object. once the pull has joined to the next document it pulls out everything again
Okay let's say I want to check if someone has hit their quota of 3 special posts this month. So I was thinking, do 30-day long window, count how many posts have been made, check against quota question: how can I achieve this with xtdb 😅
Hey @U055PQH9R4M, welcome 👋 In this case, I don't think the (1.x-style point-in-time) bitemporal queries would be the right tool for the job here - I'd probably store the 'quota date' on the document and then do a standard atemporal 'find me the special posts with a quota date in the last 30 days' query
(we generally recommend an explicit attribute in the document whenever 'creation date' or similar is important in the business domain)
I'm writing a created-at
for each entry, I'm not sure I understand your proposal my friend. Something like: "Today is June 16 and you have 3 special writes left this month" as a tuple?
I guess I am confused by the term "quota date" -- would that be the date the quota resets?
but I didn't want to assume that the date that you were using to calculate the quota was published-at
or something 🙂