Fork me on GitHub
#xtdb
<
2023-06-01
>
jjttjj14:06:54

Hi! Trying out xtdb2, using https://www.xtdb.com/v2, using the jvm-opts as described and calling:

(require '[xtdb.client :as xt.client]
         '[xtdb.api :as xt])

(def my-node (xt.client/start-client ""))

(xt/status my-node)
I'm getting a java.util.concurrent.ExecutionException (full exception in ๐Ÿงต). I'm on Windows and jdk19 EDIT: I think I realized what I'm doing wrong, brb

jjttjj15:06:19

Here's the full exeception

#error {
 :cause nil
 :via
 [{:type java.util.concurrent.ExecutionException
   :message "java.net.ConnectException"
   :at [java.util.concurrent.CompletableFuture reportGet "CompletableFuture.java" 396]}
  {:type java.net.ConnectException
   :message nil
   :at [jdk.internal.net.http.common.Utils toConnectException "Utils.java" 1045]}
  {:type java.nio.channels.ClosedChannelException
   :message nil
   :at [sun.nio.ch.SocketChannelImpl ensureOpen "SocketChannelImpl.java" 202]}]
 :trace
 [[sun.nio.ch.SocketChannelImpl ensureOpen "SocketChannelImpl.java" 202]
  [sun.nio.ch.SocketChannelImpl beginConnect "SocketChannelImpl.java" 786]
  [sun.nio.ch.SocketChannelImpl connect "SocketChannelImpl.java" 874]
  [jdk.internal.net.http.PlainHttpConnection lambda$connectAsync$1 "PlainHttpConnection.java" 208]
  [java.security.AccessController doPrivileged "AccessController.java" 569]
  [jdk.internal.net.http.PlainHttpConnection connectAsync "PlainHttpConnection.java" 210]
  [jdk.internal.net.http.PlainHttpConnection checkRetryConnect "PlainHttpConnection.java" 259]
  [jdk.internal.net.http.PlainHttpConnection lambda$connectAsync$2 "PlainHttpConnection.java" 235]
  [java.util.concurrent.CompletableFuture uniHandle "CompletableFuture.java" 934]
  [java.util.concurrent.CompletableFuture$UniHandle tryFire "CompletableFuture.java" 911]
  [java.util.concurrent.CompletableFuture postComplete "CompletableFuture.java" 510]
  [java.util.concurrent.CompletableFuture$AsyncSupply run "CompletableFuture.java" 1773]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1144]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 642]
  [java.lang.Thread run "Thread.java" 1589]]}

jjttjj15:06:57

Actually wait, I immediately realized I'm not running the server

jjttjj15:06:45

Ok I think I was confused by the second step:

Connect
Via either (1) HTTP Clojure client driver, (2) experimental SQL-only pgwire-server compatibility, or (3) use the embedded node started via your Clojure REPL (i.e. skip this step)
I wanted to just start a minimal in-memory node without postgres or anything. For that I just found that calling
(def node (xt.node/start-node {}))
and using xt/submit-tx and xt/q on that node object worked

jjttjj15:06:46

Though now I realize that the docs there don't cover that usage and are just explaining that you can use the node "server" object directly or the client object

jarohen15:06:38

hey @U064UGEUQ - yep, guide for the in-process node is https://www.xtdb.com/reference/main/installation#_in_process ๐Ÿ™‚

๐Ÿ‘ 2
jjttjj15:06:12

Thanks! Postgres is the only durable store at this point right?

jarohen15:06:45

there's a filesystem durable tx-log and object-store, although these are only suitable from being used by a single node

jjttjj15:06:20

Oh awesome, the single node file backed store is exactly what I need, thanks!

jjttjj15:06:26

in xtdb2 is there a way to match on an array within a document containing a certain value?

(xt/submit-tx node
  [[:put :things
    {:xt/id  "1"
     :name "thing1"
     :colors ["red" "green" "blue"]}]
   [:put :things
    {:xt/id  "2"
     :name   "thing2"
     :colors ["yellow"]}]])

;;; I want all the things with "blue" as a color

(xt/q node
  '{:find [colors]
    :where
    [($ :things [{:colors colors}])
     ;; failed attempts:
     ;;[(some #{"blue"} colors)]
     ;;[(= colors "blue")]
     ]
    })

jarohen17:06:56

we haven't yet added significant support for nested data structures to the Datalog language I'm afraid ๐Ÿ˜ญ

jjttjj17:06:55

Do you know if it's possible with SQL queries? I don't have experience with arrays in sql, but I'm not having any luck with variations on these https://stackoverflow.com/q/39643454

(xt/q node ["SELECT things.colors FROM things where ? = ANY(things.colors)" "blue"]
   {:default-all-valid-time? true})

 Invalid SQL query:
 - Column reference is not a grouping column: things.colors at line 1, column 8
 - WHERE clause cannot contain aggregate functions: ANY(things.colors) at line 1, column 44

jarohen15:06:46

again, not as yet I'm afraid - we've added support for nested data to the underlying query engine but not yet to the high-level languages

jarohen15:06:30

we'll be spending some time on this before alpha1 ๐Ÿ™‚ (especially now the SQL '23 spec is out)

xt 2
jjttjj15:06:30

Good to know, thanks for the info!