feat: Add APOC export procedures (Neo4j-compatible)#182
Merged
Conversation
Add CALL apoc.export.{csv|json|parquet}.query(cypher, destination, config)
for exporting query results to files and cloud storage.
Components:
- src/procedures/apoc_export.rs: Destination resolver, format mapping,
config parser, SQL builder, arg extractor (29 unit tests)
- HTTP handler intercept with sql_only support
- Bolt protocol handler intercept with full inner Cypher pipeline
- Embedded mode: handle_export_call() in Connection (3 tests)
Parser fix: Standalone CALL with positional args now correctly parsed
even when inner Cypher contains RETURN/UNION keywords. Replaced naive
substring check with try-standalone-first-then-verify approach.
Supported destinations: local files, s3://, gs://, azure://, http(s)://
Supported formats: CSV, JSON, Parquet (with compression config)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Neo4j APOC-compatible export procedures (CALL apoc.export.{csv|json|parquet}.query(cypher, destination, config)) to ClickGraph, enabling users to export query results to local files, S3, GCS, Azure Blob Storage, or HTTP endpoints. It also fixes the standalone CALL parser, which previously failed to parse export calls containing RETURN/UNION in the inner Cypher string.
Changes:
- Core export module (
src/procedures/apoc_export.rs): New module implementing destination URI resolution, format mapping, SQL generation, and argument parsing for APOC export procedures, with 29 unit tests. - Handler intercepts: Export procedure handling injected into the HTTP handler (
handlers.rs), Bolt protocol handler (bolt_protocol/handler.rs), and embedded mode connection (clickgraph-embedded/src/connection.rs), each running the inner Cypher through the full planning pipeline. - Parser fix (
src/open_cypher_parser/mod.rs): Replaced naiveinput.contains("RETURN")check with a try-first-verify-consumed approach, enabling standalone CALL with positional string arguments that happen to containRETURNorUNION.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/procedures/apoc_export.rs |
New core module: destination resolver, format mapping, config parsing, SQL builder, 29 tests |
src/procedures/mod.rs |
Exposes apoc_export as public submodule |
src/open_cypher_parser/mod.rs |
Parser fix: standalone CALL now correctly handles positional args with inner Cypher strings |
src/server/handlers.rs |
HTTP export intercept + translate_cypher_to_sql() helper function |
src/server/bolt_protocol/handler.rs |
Bolt export intercept with inline inner Cypher pipeline |
clickgraph-embedded/src/connection.rs |
Embedded export handler + 3 new tests |
docs/wiki/Cypher-Language-Reference.md |
New Export Procedures section with syntax, formats, examples |
docs/wiki/Embedded-Mode.md |
APOC export usage examples for embedded mode |
STATUS.md |
Documents APOC export as completed feature |
CHANGELOG.md |
Records feature addition |
1. Add blank line between functions in handlers.rs 2. Remove time_ms from HTTP export response for cross-mode consistency 3. Pass role.as_deref() in Bolt export (was None, bypassing RBAC) 4. Add set_current_schema() in Bolt export handler 5. Use schema_name param with debug log instead of underscore 6. Log export timing instead of including in response 7. Replace string-based APOC detection in embedded with parsed approach Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Neo4j APOC-compatible export procedures that work across all ClickGraph modes: HTTP server, Bolt protocol, and embedded.
Syntax
Architecture
INSERT INTO FUNCTIONtable functionsfile(), S3 →s3(), GCS →s3(), Azure →azureBlobStorage(), HTTP →url()Parser Fix
Fixed standalone CALL parsing when inner Cypher contains RETURN/UNION keywords. Replaced naive `input.contains("RETURN")" substring check with try-standalone-first, verify-consumed-everything approach.
Changes
src/procedures/apoc_export.rssrc/server/handlers.rstranslate_cypher_to_sql()helpersrc/server/bolt_protocol/handler.rsclickgraph-embedded/src/connection.rshandle_export_call()+ 3 testssrc/open_cypher_parser/mod.rsTests