-
Notifications
You must be signed in to change notification settings - Fork 346
feat(extensions): Add Apache AGE graph database extension #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add support for Apache AGE (A Graph Extension) which brings graph
database capabilities and the Cypher query language to PGlite.
Features:
- Full Cypher query language support
- Create/query/update/delete graph nodes and relationships
- Variable-length path queries
- Integration with standard SQL
New files:
- packages/pglite/src/age/index.ts - Extension wrapper
- packages/pglite/tests/age.test.ts - Test suite (43 tests)
- docs/extensions/age.md - User documentation
Modified files:
- package.json - Add ./age export
- tsup.config.ts - Add entry point
- bundle-wasm.ts - Add path replacement
Usage:
import { PGlite } from '@electric-sql/pglite'
import { age } from '@electric-sql/pglite/age'
const pg = new PGlite({ extensions: { age } })
await pg.exec("SELECT ag_catalog.create_graph('my_graph');")
Requires: electric-sql/postgres-pglite PR for build system changes
Depends on: apache/age 32-bit compatibility (jpabbuehl/age fork)
|
@jpabbuehl Thank you for this! We are having a bit of time off atm, but we'll have a look at this as soon as we're back. I know it's a lot to ask, but would it be possible to upstream your changes for 32bit support to the official AGE repo? |
|
Here it is. |
|
@jpabbuehl We really like this but we are not quite ready to link to individual's repos. It would be great to have that PR merged on the Apache repo. Will comment there as well. One other option would be for us to make a fork of the main repo and apply your changes there. The issue with this approach is that we'll be left maintaining it and we are tight on resources... |
- Update submodule to include SIZEOF_DATUM=4 build flag for AGE - Minor code style fixes (quote consistency)
|
@tdrz updated to latest Apache Age PR. let's wait and see how it goes upstream :) |
|
@tdrz merged upstream. I've updated this PR and the other for Build with the Parameter 32bit. Happy to hear if something is missing |
@jpabbuehl |
|
@tdrz I updated the submodule link, including electric-sql/postgres-pglite#58 Hope all is good |
@jpabbuehl Thank you! There seems to be a conflict with postgres-pglite, could you please have a look? |
|
My 32-bit fix was merged to upstream master (#2286, included in #2311). However, upstream master has since moved to PG18 (#2315), so the build now fails with PG18 API incompatibilities: Since PGlite is still on PG17.5, I'd need the fix backported to AGE's PG17 branch. @tdrz What do you think? Should I open a backport PR on apache/age for PG17, or is PGlite planning to upgrade to PG18 soon? |
💯
@jpabbuehl That's very unfortunate, I was looking forward to deploying this soon. :(
As we don't have a clear date when we'll upgrade PGlite to PG18, I think it would be best to try to backport it to PG17 on AGE's repo. Thank you for your efforts, I know it must be a blow... |
|
opened a PR apache/age#2321 |
|
will come soon apache/age#2321 (comment) |
Summary
Add support for Apache AGE (A Graph Extension), bringing graph database capabilities and the Cypher query language to PGlite.
What is AGE?
Apache AGE is a PostgreSQL extension that adds:
Usage
Changes
New Files
packages/pglite/src/age/index.tspackages/pglite/tests/age.test.tsdocs/extensions/age.mdModified Files
packages/pglite/package.json./ageexportpackages/pglite/tsup.config.tssrc/age/index.tsentry pointpackages/pglite/scripts/bundle-wasm.tsTechnical Details
Extension Initialization
The wrapper handles:
CREATE EXTENSION IF NOT EXISTS ageLOAD 'age'(activates Cypher parser hooks)SET search_path(includesag_catalogfor operator class resolution)32-bit WASM Compatibility
AGE required patches for PGlite's 32-bit WASM environment. The
postgres-pglitePR includes AGE as a submodule from a fork with a Makefile-only patch that stripsPASSEDBYVALUEfrom thegraphidtype at build time whenSIZEOF_DATUM=4is passed.Documentation
Full documentation added at
docs/extensions/age.md:Limitations
load_labels_from_file()not available (no filesystem in WASM)Related PRs
Checklist
pnpm test)pnpm test:web)