Skip to content

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

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
Collaborator

What

Port of humemai/arcadedb-embedded-python#519. Database.insert_many into a VERTEX type raised on the JVM build (ArcadeDBError: ... IllegalArgumentException: Cannot create a document of type 'Doc' because is not a document type), while the native build accepted the same call and stored vertices. Both builds share one API, so the JVM build 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, and the insert_many / insert_columns docstrings say a vertex type is accepted. This repo's Antora docs do not describe insert_many yet, so there is no page to change.
  • 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. With the stock bridge jar and this repo's unchanged Python, 6 of the 8 fail with the error above; with the fix all 8 pass.

Local checks that ran

  • Red: the new class against the stock engine and bridge jars (26.11.1-SNAPSHOT, from the main humemai wheel) with this repo's unchanged src/arcadedb: 6 failed, 2 passed (the edge-type and missing-type tests pass before and after).
  • Green, Python 3.12: the bridge jar rebuilt with javac --release 21 from this tree's src/java and overlaid on those jars together with this tree's src/arcadedb: new class 8 passed; test_bulk_insert.py, test_bridge_fixes.py, test_float_vector_bulk.py, test_bulk_json_paths.py, test_async_executor.py: 163 passed.
  • Green, Python 3.10 (the lowest supported): test_bulk_insert.py and test_bridge_fixes.py: 50 passed. The change uses nothing newer than 3.10.
  • black --check, isort --profile black on the touched files (the pre-commit hooks passed on commit).
  • Not run: the full suite and a real wheel build (CI).

🤖 Generated with Claude Code

tae898 and others added 2 commits October 25, 2026 16:18
On the JVM build, insert_many into a VERTEX type raised ArcadeDBError (IllegalArgumentException: Cannot create a document of type ... because is not a document type), while the native build 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 bridge jar (6 of 8) and passes with the fix.

Port of humemai/arcadedb-embedded-python#519.

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 d0b13f7 into main Oct 25, 2026
46 checks passed
@tae898
tae898 deleted the fix/insert-many-vertex-type branch October 25, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant