xtdb 2024-07-14

🙋 Hi, in v2, how should I reference a nested object key/property in a select? 🧵

For example, after this insert:

INSERT INTO locations (_id, owner)
VALUES (1, {id: 'foo'})
This select doesn’t return what I’d hoped:
SELECT _id, owner.id
FROM locations
it returns only:
| _id |
|-----|
| 1   |
What am I missing? Are there any docs where I could have looked this up? I did try searching, I promise...

Thanks! Is that written anywhere in the docs?

I don't believe so, I seem to remember it came from the SQL standard. One to improve on either way!

👍 1

Ah, found this issue that explains things: https://github.com/xtdb/xtdb/issues/3436

👏 1

I'm just pondering here on the hammock, could a fully reactive API for XTDB be built if there was an r2dbc driver for apache arrow?

Hey @pafitisnick https://github.com/apache/arrow-adbc/issues/547 would be a good upstream ADBC drive issue to track / subscribe to Longer term though I don't know if r2dbc has a meaningful role if everyone switches to using virtual threads - looking at https://mariadb.com/resources/blog/benchmark-jdbc-connectors-and-java-21-virtual-threads/ > [...] in terms of performance, virtual threads dethrone R2DBC

How would vthreads help with reactivity though?

ah right, I was thinking about async more generally - but I guess you mean more like for listening to tx-log changes? or if we were to implement Incremental View Maintenance?

I'm thinking of queries that efficiently listen to changes

👍 1

a reactive tx-log listener query like SELECT * FROM _txs ORDER BY _id ASC would be viable in the not-so-distant future, but what other kinds of queries are you hoping to be efficiently reactive? Anything that involves a join is like not possible without introducing an IVM engine (or if you can tolerate some latency then batch materialized view recalculations could be useful here also)

I think I misunderstood r2dbc

I'm just trying to find a database that I can use in my hyperfiddle/electric apps, that would allow to make a query and stream any changes, thus be able to make highly interactive realtime webapps

👍 1

It's a trend, where a lot of databases support "reactive" (or "live", "real-time") queries, an example is retthink, pocketbase, convex, surreal etc. Ideally for me I'd want to use XTDB, for all the other features XTDB provides, (bitemporality, graph queries, edn native and so on)

🙋 Hi, another v2 SQL question, this time about joining across tables… 🧵

This is another one of those nested columns not being accessed correctly issues.

Jinx

I’m running first two insert statements:

INSERT INTO partners (_id, name)
VALUES (1, 'Aptera')

INSERT INTO partner_locations (_id, partner, name)
VALUES (1, {id: 1}, 'Carlsbad')
and then I’m trying to join across these two "tables":
select p.name, pl.name as location_name
from partners p
  left outer join partner_locations pl on pl.partner.id = p._id
But I’m only getting back the first column name; no column named location_name is coming back. What am I doing wrong here?