xtdb

torkan 2024-09-23T08:50:22.055039Z

Hi! Congrats on getting the 2.0 beta up and running! Not sure if this is the correct place to ask, but here goes: Is there a ballpark timeline/roadmap for implementing the non-clojure client libs?

refset 2024-11-12T18:21:57.520179Z

Hi folks, apologies for resurrecting an old thread, but just in case you didn't already read the latest release notes - we now have working Postgrex support: https://docs.xtdb.com/clients/elixir.html

๐Ÿ™Œ 1
jarohen 2024-09-25T09:01:05.752189Z

@torkan https://github.com/xtdb/xtdb/issues/3737 if you'd like to follow its progress

๐Ÿคฉ 1
torkan 2024-09-25T09:02:04.864619Z

Excellent! ๐Ÿ˜„ Thanks!

๐Ÿ™ 1
torkan 2024-09-25T09:02:58.977169Z

Exciting that my days of the insanity that is update-in-place might be coming to an end in the not too distant future ๐Ÿ˜›

๐Ÿ˜ 1
torkan 2024-09-25T09:05:24.562089Z

Have you guys landed on "how much of postgres" you will aim to emulate btw?

jarohen 2024-09-25T09:06:49.457149Z

Enoughโ„ข haha

๐Ÿ˜† 1
jarohen 2024-09-25T09:07:28.474319Z

joking aside, it'll be enough to get the tools working and understanding what's in the database, but we're saying that the end-user should be expecting to talk XTDB rather than Postgres

torkan 2024-09-25T09:08:31.396909Z

Yeah, completely understandable really

jarohen 2024-09-25T09:09:14.177789Z

i.e. we're explicitly not going down the 'we're drop-in compatible, you won't be able to tell the difference' route (as a number of other Postgres wire-compatible dbs have) - it's a completely reasonable avenue, just not the one we want to go down ๐Ÿ™‚

torkan 2024-09-25T09:12:16.634169Z

Yes, I'll definitely miss pg_trgrm for easily-setup searching, but other than that it's still an excellent trade-off imo ๐Ÿ˜›

jarohen 2024-09-25T09:14:22.626749Z

well, I won't rule it out, there's nothing technical stopping us (or someone else, given it's F/OSS!) implementing that on top of XT - it's the usual "time/resources" issue ๐Ÿ™‚ (and indeed, we've added a number of Postgres SQL functions/extensions already)

torkan 2024-09-25T09:15:06.488619Z

Ah, so you're doing a little of that as well, very cool!

torkan 2024-09-25T09:21:14.848549Z

Not sure how familiar you are with the Elixir ecosystem, but if setting up a new Phoenix project with postgres works, then you're golden ๐Ÿ˜›

๐Ÿคž 1
jarohen 2024-09-25T09:43:36.090389Z

personally, not at all, I'm afraid ๐Ÿ˜… but we have a few Elixir folk at JUXT I'm hoping to entice into writing the test harness

torkan 2024-09-25T09:44:58.194609Z

Haha, well then they'll set you straight once they start trying it out ๐Ÿ˜†

๐Ÿ’ฏ 1
torkan 2024-09-25T09:50:18.057439Z

Ecto (the main db lib/wrapper) is fairly opinionated, and assumes it will be handling automatic migrations etc when using Postgres, but all of that can be easily bypassed

tatut 2024-09-25T09:52:27.348379Z

yes, I did an Erlang library for xtdb v1 that mapped erlang records and/or elixir structs to documentsโ€ฆ and I didnโ€™t use ecto at all. but perhaps v2 can use it better due to being SQL

torkan 2024-09-25T09:58:30.962559Z

Yeah, writing an ecto-adapter for v1 would be quite an undertaking I'm guessing ๐Ÿ˜…

tatut 2024-09-25T09:59:14.901219Z

xtdb v2 does more than postgresql, as you can so neatly use NEST_MANY to pull linked dataโ€ฆ no need to do what most SQL abstractions spend lots of code doing: turning rectangular resutls back into nested data

๐Ÿ‘ 1
โ˜บ๏ธ 1
jarohen 2024-09-25T10:01:24.734759Z

it was definitely a missing piece for us, yeah โ˜บ๏ธ > spend lots of code doing: turning rectangular results back into nested data spent far too much of my pre-XTDB life doing exactly that ๐Ÿ˜…

torkan 2024-09-25T10:02:20.692219Z

Haha yes

torkan 2024-09-25T10:04:41.356359Z

That one will be probably off limits when just using the standard ecto postgres-adapter though, due to all the automatic type casting etc that relies on the table schema introspections

torkan 2024-09-25T10:07:30.344439Z

But I don't see it as unlikely that there will be enough community excitement to make that happen ๐Ÿ™

torkan 2024-09-25T10:23:26.236279Z

Fwiw I just reached out to the ecto-team in the elixir slack, if I hear anything worthwhile back from them I'll post it here

๐Ÿ™ 1
jarohen 2024-09-23T09:03:45.200069Z

hey, thanks @torkan โ˜บ๏ธ tbh, we're not as likely to now that we have better PostgreSQL tooling compatibility - we're already using XT2 from both NodeJS and Python using their normal Postgres drivers. We're currently going through a bug bash on the queries the different drivers/tools throw at us, so if you run into anything with yours, please do let us know ๐Ÿ™‚

torkan 2024-09-23T09:08:02.950349Z

A very understandable approach ๐Ÿ˜„ Some of the de-facto drivers/client libs in other languages have quite a bit of very postgres-specific behavior that in practice makes xtdb incompatible atm

torkan 2024-09-23T09:10:43.673579Z

For example, Postgrex in Elixir queries the db for expected types, which makes it just crash ๐Ÿ˜…

jarohen 2024-09-23T09:10:56.484959Z

Heh, yep, we've been running into all of those ๐Ÿ˜… we should be significantly better on this now though, so if you're hitting any specific issues with your driver of choice, could you file a bug?

jarohen 2024-09-23T09:11:11.760449Z

aha, Elixir, niice ๐Ÿ™‚

jarohen 2024-09-23T09:11:18.499659Z

one we haven't tried, openly ๐Ÿ˜„

jarohen 2024-09-23T09:11:48.535739Z

we also have a 'nightly' Docker label which contains a good few fixes over the b1 tag - could you give that a try?

torkan 2024-09-23T09:12:24.125999Z

Ah nice, will definitely try it out

jarohen 2024-09-23T09:13:19.693289Z

are you using Postgrex?

torkan 2024-09-23T09:13:44.444859Z

Yup!

torkan 2024-09-23T09:16:14.650029Z

I assume 99% of all elixir users would want to be able to use Ecto (a db-agnostic abstraction for defining schemas/queries/etc), which in turn has an adapter for using Postgrex

torkan 2024-09-23T09:22:01.253769Z

On nightly:

09:21:18 | DEBUG xtdb.pgwire | Interpreting SQL:  SELECT t.oid, t.typname, t.typsend, t.typreceive, t.typoutput, t.typinput,
       coalesce(d.typelem, t.typelem), coalesce(r.rngsubtype, 0), ARRAY (
  SELECT a.atttypid
  FROM pg_attribute AS a
  WHERE a.attrelid = t.typrelid AND a.attnum > 0 AND NOT a.attisdropped
  ORDER BY a.attnum
)

FROM pg_type AS t
LEFT JOIN pg_type AS d ON t.typbasetype = d.oid
LEFT JOIN pg_range AS r ON r.rngtypid = t.oid OR r.rngmultitypid = t.oid OR (t.typbasetype <> 0 AND r.rngtypid = t.typbasetype)
WHERE (t.typrelid = 0)
AND (t.typelem = 0 OR NOT EXISTS (SELECT 1 FROM pg_catalog.pg_type s WHERE s.typrelid != 0 AND s.oid = t.typelem))

torkan 2024-09-23T09:23:45.046219Z

I'm assuming this is due to Postgrex using binary-mode, and wants to know how to handle the response and map the types

jarohen 2024-09-23T09:44:37.953849Z

right, yep - my guess would be that we don't have pg_range yet, but will file an issue for it and see what we can repro ๐Ÿ™‚ thanks for getting in touch!

torkan 2024-09-23T09:45:59.669969Z

Ah right, so your long-term ambition is to basically be more or less completely "pg-compatible"?

torkan 2024-09-23T09:49:07.385089Z

I'd imagine it'll be hard to replicate the pg_type table for example, since it's all built on the assumption that tables conform to a given schema ๐Ÿ˜…

jarohen 2024-09-23T10:00:11.946299Z

yep, that's the plan (at least for outside of Clojure) - the idea being we get so much benefit from tooling/libraries if we can achieve that

jarohen 2024-09-23T10:00:52.715869Z

pg_type's one of the better ones - the difference with us is that rather than returning the schema specified through create/alter table, we return the schema inserted through the documents themselves

tatut 2024-09-23T10:01:22.964309Z

fwiw, Iโ€™ve been using the HTTP API (not in production) and it is very simple to use from basically any language that has http client and json support

torkan 2024-09-23T10:03:06.479809Z

Being pg-compatible is definitely the way I would go as well, so makes total sense!

jarohen 2024-09-23T10:03:54.901609Z

@tatut mm, it's good, and I can't pretend I don't enjoy being able to 'curl' my database - but the API itself is bespoke to us, so we'd also need to have written database exploration UIs, BI tools, etc etc, which (in addition to the database itself!) is realistically too much for our relatively small team

torkan 2024-09-23T10:04:22.001949Z

And yes, I was wondering about the http api as well, it would probably be a nice workaround until regular wire protocol "just works" ๐Ÿ˜›

jarohen 2024-09-23T10:04:51.434439Z

well, or rely on open-source contributions like xtdb-inspector, of course ๐Ÿ™‚

jarohen 2024-09-23T10:05:59.560549Z

@torkan exactly, yep - it was our quickest route to being able to get data in and out of XT2

torkan 2024-09-23T10:08:05.118189Z

There's no docs for it, right? I'm fine with just reading the code for the remote client, just wondering if I've missed it somewhere ๐Ÿ˜…

tatut 2024-09-23T10:08:30.895419Z

yes, the API is obviously xtdb2 specificโ€ฆ I see that, but a maximal xtdb2 client library probably would go ways beyond โ€œgeneric SQLโ€ imo

tatut 2024-09-23T10:09:34.065209Z

I enjoyed making my Prolog libraryโ€ฆ https://github.com/tatut/swixt and even that still doesnโ€™t make use of everything xtdb2

torkan 2024-09-23T10:16:08.723579Z

Nice, thanks for sharing!

jarohen 2024-09-23T10:25:04.083959Z

@tatut we don't have a lot of extensions in the HTTP API outside of the query languages themselves - it's mostly status information (which we're looking to expose through more standard monitoring interfaces too)

tatut 2024-09-23T10:37:23.856269Z

why not expose those as virtual tables?

jarohen 2024-09-23T10:46:53.595399Z

that too, yep ๐Ÿ™‚

tatut 2024-09-23T10:48:10.796849Z

I really liked that the API is drop dead simple, query and txโ€ฆ thatโ€™s it

โž• 2