🙋 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...I can't remember the reason, but you have to put https://play.xtdb.com/?version=2.0.0-SNAPSHOT&type=sql&txs=W3sic3lzdGVtLXRpbWUiOm51bGwsInR4cyI6IklOU0VSVCBJTlRPIGxvY2F0aW9ucyAoX2lkLCBvd25lcilcbiBWQUxVRVMgKDEsIHtpZDogJ2Zvbyd9KSJ9XQ%3D%3D&query=U0VMRUNUIF9pZCwgKG93bmVyKS5pZCBGUk9NIGxvY2F0aW9ucw%3D%3D.
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!
Ah, found this issue that explains things: https://github.com/xtdb/xtdb/issues/3436
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
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
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.
Looks like you're running afoul of that nested column access syntax again. Putting brackets around (pl.partner) https://play.xtdb.com/?version=2.0.0-SNAPSHOT&type=sql&txs=W3sic3lzdGVtLXRpbWUiOm51bGwsInR4cyI6IklOU0VSVCBJTlRPIHBhcnRuZXJzIChfaWQsIG5hbWUpIFZBTFVFUyAoMSwgJ0FwdGVyYScpIn0seyJ0eHMiOiJJTlNFUlQgSU5UTyBwYXJ0bmVyX2xvY2F0aW9ucyAoX2lkLCBwYXJ0bmVyLCBuYW1lKVxuVkFMVUVTICgxLCB7aWQ6IDF9LCAnQ2FybHNiYWQnKSIsInN5c3RlbS10aW1lIjpudWxsfV0%3D&query=c2VsZWN0IHAubmFtZSwgcGwubmFtZSBhcyBsb2NhdGlvbl9uYW1lCmZyb20gcGFydG5lcnMgcAogIGxlZnQgb3V0ZXIgam9pbiBwYXJ0bmVyX2xvY2F0aW9ucyBwbCBvbiAocGwucGFydG5lcikuaWQgPSBwLl9pZA%3D%3D
Jinx
Thank you!
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?