Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

Bindings: insert_many and insert_columns load a vertex type as vertices (JVM/native parity) - #519

Merged
tae898 merged 2 commits into
mainfrom
fix/insert-many-vertex-type
Oct 25, 2026
Merged

tae898 merged 2 commits into
mainfrom
fix/insert-many-vertex-type

Conversation

@tae898

@tae898 tae898 commented Oct 25, 2026

Copy link
Copy Markdown

What

Database.insert_many into a VERTEX type raised on the JVM wheel (ArcadeDBError: ... IllegalArgumentException: Cannot create a document of type 'Doc' because is not a document type), while the native wheel accepted the same call and stored vertices. Both wheels share one API, so the JVM wheel now does what the native one does.

Cause

The Java helper DocumentBatcher called db.newDocument(typeName) for every row, and newDocument refuses a vertex type. The Python per-row fallback in _insert_many_chunk (values the JSON text cannot carry, such as datetime) called new_document for the same reason.

Fix

  • DocumentBatcher resolves the type once per call (no per-row schema lookup) and calls db.newVertex for a vertex type, in all four entry points: insertManyJson, insertManyJsonParallel, insertColumns, insertColumnsParallel. So insert_columns (also parallel=True) loads a vertex type too.
  • An edge type is refused with a message that says why (an edge needs both endpoints), still as ArcadeDBError. A missing type still raises the schema's own SchemaException text.
  • The Python fallback uses new_vertex for a vertex type.
  • Docs: insert_many and insert_columns take a document or a vertex type (docs/api/database.md and the docstrings). No other doc or example says insert_many is documents-only: the other mentions describe it as the document path, which it still is. insert_dataframe and insert_arrow are unchanged (a vertex type still goes through GraphBatch.create_vertices()).

Tests

New TestInsertManyVertexType in tests/test_bulk_insert.py: synchronous load, parallel=True, the non-JSON fallback, inside a caller's transaction (rollback leaves nothing, commit keeps all), insert_columns, insert_columns(parallel=True), an edge type, and a missing type. Each load checks the count and that CREATE EDGE can join two of the new records, which only works for real vertices. On the stock main wheel 6 of the 8 fail with the error above; with the fix all 8 pass.

The same synchronous load on the native wheel (dev1 image) stores vertices and takes an edge, so the behaviour matches. Not part of this PR, noted for the native side: on that image insert_many(..., parallel=True) into a vertex type still raises the same IllegalArgumentException, because the parallel path goes through the Java helper. This PR fixes that helper for the JVM wheel.

Local checks that ran

  • Red: the new class against the stock main wheel (26.11.1.dev0, 78e97b1cff): 6 failed, 2 passed (the edge-type and missing-type tests pass before and after).
  • Green: the bridge jar rebuilt with javac --release 21 from this tree and overlaid on that wheel together with this tree's Python: new class 8 passed.
  • Near the change, same overlay: test_bulk_insert.py, test_bridge_fixes.py, test_float_vector_bulk.py, test_insert_columns.py, test_dataframe_ingest.py, test_async_executor.py: 137 passed, 1 skipped (a skip those files already have). After the last edit (the isort pass of the pre-commit hook) test_bulk_insert.py and test_bridge_fixes.py on the committed tree: 50 passed.
  • black --check, isort (pre-commit hooks passed on commit).
  • Not run: the full suite and the wheel build in CI.

🤖 Generated with Claude Code

On the JVM wheel, insert_many into a VERTEX type raised ArcadeDBError (IllegalArgumentException: Cannot create a document of type ... because is not a document type), while the native wheel accepted it and stored vertices. The Java helper (DocumentBatcher) called db.newDocument for every row, and so did the Python per-row fallback for values the JSON text cannot carry.

DocumentBatcher resolves the type once per call and calls db.newVertex for a vertex type, in all four entry points (insertManyJson, insertManyJsonParallel, insertColumns, insertColumnsParallel). An edge type is refused with a message that says why (an edge needs both endpoints); a missing type still raises the schema's SchemaException. The Python fallback uses new_vertex for a vertex type.

Tests: TestInsertManyVertexType (synchronous, parallel, the non-JSON fallback, inside a caller's transaction with rollback and commit, insert_columns, insert_columns(parallel=True), an edge type, a missing type). Each load checks the count and that an edge can join two of the new records. The new class fails on the stock wheel (6 of 8) and passes with the fix.

Docs: insert_many and insert_columns take a document or a vertex type.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…(test-owned type names)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tae898
tae898 merged commit 7890ca7 into main Oct 25, 2026
58 of 63 checks passed
@tae898
tae898 deleted the fix/insert-many-vertex-type branch October 25, 2026 09:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant