graphjin icon indicating copy to clipboard operation
graphjin copied to clipboard

Test Super Graph with Cockroach DB

Open dosco opened this issue 5 years ago • 9 comments

What would you like to be added:

Document what it would take to get Super Graph working with Cockroach DB a distributed database that is designed to be compatible with Postgres. Super Graph makes use of a bunch of Postgres specific features like querying for database tables and columns, lateral joins, json functions etc. I have never tried using Super Graph with Cockroach if someone can take the time to do this and document what worked and what did not. And maybe what it would take to get this working.

Why is this needed:

Since Cockroach DB is Postgres compatible this would help Super Graph work with a massively scalable distributed database and possibly help the Cockroach DB team see what gaps can be filled in their compatibility layer.

dosco avatar Dec 11 '19 04:12 dosco

Hello,

Would be a nice feature but several features are lacking:

https://www.cockroachlabs.com/docs/v19.2/postgresql-compatibility.html#unsupported-features

The authorization generator supergraph already implemented could cover the lack of RLS, and lateral joins appear to have recently been implemented.

What bothers me the most is lack of stored procedures, triggers and events. Will be very hard to implement subscriptions, requiring polling, what could overload the server...

howesteve avatar Dec 12 '19 13:12 howesteve

I don't expect a distributed DB to match Postgres feature for feature mostly since implementing these features on a distributed system is much harder than a monolith like Postgres. I'm mostly looking to test if the SQL generated by Super Graph works on Cockroach DB. Lack of RLS, Triggers etc does not affect Super Graph. In almost all distributed DB's those features are implemented app side or using a separate service like Kafka.

dosco avatar Dec 12 '19 15:12 dosco

how about yugabyte it has stored Procedures and Triggers

I did not test it though so I don't know if it fits.

jinxmcg avatar Jan 02 '20 18:01 jinxmcg

Sure sounds like a great idea. I did some digging and it seems Yugabyte is Postgres compatible and quite feature rich too. I created a separate ticket to track this. #29

dosco avatar Jan 03 '20 05:01 dosco

@jinxmcg FYI Yugabyte works with Super Graph https://supergraph.dev/guide.html#yugabytedb

dosco avatar Feb 23 '20 10:02 dosco

How is Cockroach DB compatibility going? Thanks

paulm17 avatar Apr 27 '22 08:04 paulm17

I have a test in place but haven't gotten around to playing with it more. https://github.com/dosco/graphjin/blob/00c26bab4c922073ebe09a5b2845fdb466d9832d/core/core_test.go

cd core
go test -v -db cockroach ./...

dosco avatar Apr 27 '22 08:04 dosco

Thanks for bringing this up. I got curious seems like it's not too bad most tests pass (fake fail) the tests mostly all pass the failures are because cockcoach seems to randomly sort json key-values. Probably cause they use Go maps internally which has this behaviour. In short the result is correct the test fails to compare the values correctly.

subs_test.go:201: expected '{"users": {"id": 42, "email": "[email protected]"}}' got '{"users": {"email": "[email protected]", "id": 42}}'

dosco avatar Apr 27 '22 08:04 dosco

Sounds good. Right now I'm developing against Postgres. I'll take a look with CDB when I get some free time next week and will follow up.

paulm17 avatar Apr 27 '22 08:04 paulm17

this exists.

dosco avatar Oct 01 '22 17:10 dosco