Fork me on GitHub
#xtdb
<
2023-07-20
>
zeitstein05:07:15

Can subqueries take dynamic query maps? Specifically, I have something like this in mind:

(->> [{:xt/id 1 :query '{:find [e] :where [[e :data 2]]}}
        {:xt/id 2 :data 2}]
       (mapv #(vector ::xt/put %))
       (xt/submit-tx node))

  ;; error: query didn't match expected structure
  (xt/q (xt/db node)
    '{:find [x]
      :where [[1 :query stored-query]
              [(q stored-query) x]]})

zeitstein05:07:09

I also tried storing the query map as a string, with same results.

refset17:07:19

Hey, you can either get creative with quoting, or walk the quoted form to conj your query on the '(q) list

zeitstein18:07:19

Right, but this would require knowing the subquery map ahead of time 🙂 I have a half-baked idea where an attribute's value would be interpreted as results of some query. So, to read the value (e.g. in the middle of a larger query), you'd have to run the (sub)query first.

👍 2
zeitstein18:07:28

Oh, I could use a custom function that just runs xt/q.

💯 2
Vincent19:07:09

When would one see the NO_SOURCE_FILE error? I am encountering it time to time on my prod box

refset10:07:48

Hey @U055PQH9R4M is there a stacktrace that goes along with that?

hairfire19:07:03

Can anyone point me to a working example of XTDB 1.x that uses the SQL interface?

seancorfield19:07:31

Does 1.x even have a SQL interface?

hairfire19:07:49

BTW, @U04V70XH6, thanks for all the great work you do for the Clojure community 🤓

hairfire19:07:52

I'm having trouble getting the code on that page to work (see https://clojurians.slack.com/archives/CG3AM2F7V/p1689803380004219), and I was just wondering if anyone had some working code I could use as a guide

seancorfield20:07:31

(query "SELECT PERSON.NAME FROM PERSON")
is missing the node as the first parameter in the docs.

seancorfield20:07:06

(I see you have it in your code tho')

👍 2
seancorfield20:07:33

Hmm, I can't remember whether I ever tried the Calcite stuff with 1.x... certainly not with recent releases anyway... maybe post on https://discuss.xtdb.com/ -- I think that might get seen by more XTDB users?

👍 2
seancorfield20:07:28

Looks like the XTDB team were trying to help yesterday with your previous post -- remember they're nearly all on UK time so they might not respond for a day's cycle...

hairfire20:07:31

Got it. I'm not in a hurry. I'm preparing a presentation for my coworkers that I will deliver next Wed.

hairfire20:07:27

I hate to cross-post, but perhaps it would benefit some XTDB users if I asked about examples of XTDB 1.x with SQL over on http://discuss.xtdb.com. Thoughts?

seancorfield20:07:33

I'd give the team another day to respond here first...

👍 2
🙏 2
jarohen10:07:22

hey @U44P1CP5K 🙂 I think you'd be among the first, if I'm honest - we haven't ever had a lot of questions on it, particularly since the 2.x announcement, so you might be the one taking all the cobwebs for the team 😅

refset11:07:57

> I was just wondering if anyone had some working code I could use as a guide Hi @U44P1CP5K this works on my machine: https://gist.github.com/refset/f10bff23d199039a74badfab82c5fb1d

hairfire13:07:56

Thanks, XTDB team, I'll take a look, and let you know