GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support validation with Gremlin "addVertex" through Postgres driver · Issue #690 · ArcadeData/arcadedb

Support validation with Gremlin "addVertex" through Postgres driver #690

New issue
Copy link
New issue
Copy link
Closed
Closed
Support validation with Gremlin "addVertex" through Postgres driver#690
Copy link
Assignees
lvca
Milestone
22.12.1

Description

@docbacardi
docbacardi
opened on Dec 19, 2022
Issue body actions

ArcadeDB Version: 22.12.1-SNAPSHOT

JDK Version: openjdk version "11.0.17" 2022-10-18

OS: Ubuntu 22.04.1 LTS

Expected behavior

I have created a vertex type with 2 properties with the following SQL commands:

chicken@asteroid:~$ psql --host=localhost testdatabase root
Password for user root: 
psql (14.5 (Ubuntu 14.5-0ubuntu0.22.04.1), server 10.5)
Type "help" for help.

testdatabase=> CREATE VERTEX TYPE ChipID;
     operation      | typeName 
--------------------+----------
 create vertex type | ChipID
(1 row)

INSERT 0 1
testdatabase=> CREATE PROPERTY ChipID.name STRING (mandatory true, notnull true, readonly true);
    operation    | typeName | propertyName | mandatory | notnull | readonly 
-----------------+----------+--------------+-----------+---------+----------
 create property | ChipID   | name         | \x01      | \x01    | \x01
(1 row)

testdatabase=> CREATE PROPERTY ChipID.uid STRING (mandatory true, notnull true, readonly true);
    operation    | typeName | propertyName | mandatory | notnull | readonly 
-----------------+----------+--------------+-----------+---------+----------
 create property | ChipID   | uid          | \x01      | \x01    | \x01
(1 row)

Both name and uid are "readonly", which means they have to be present at creation time. It is expected that the following command fails:

testdatabase=> {gremlin} g.addV('ChipID').property('name', 'a').property('uid', 'b');
ERROR:  Error on executing query: The property 'name' is mandatory, but not found on document: @ChipID[uid=b]

I'm looking for a way to create a ChipID vertex through the Postgres Driver in Gremlin.

A Gremlin graph has an "addVertex" method which looks like the right choice, but I have no idea how to access it.
Both graph and testdatabase (the name of my database) did not work:

testdatabase=> {gremlin} graph.addVertex('ChipID', 'name', 'a', 'uid', 'b');
ERROR:  Syntax error on executing query: groovy.lang.MissingPropertyException: No such property: graph for class: Script23
testdatabase=> {gremlin} testdatabase.addVertex('ChipID', 'name', 'a', 'uid', 'b');
ERROR:  Syntax error on executing query: groovy.lang.MissingPropertyException: No such property: testdatabase for class: Script24

Activity

  1. lvca
    self-assigned this
    on Dec 19, 2022
  2. lvca commented on Dec 19, 2022

    @lvca
    lvca
    on Dec 19, 2022
    Member
    More actions

    The issue with the Gremlin API is that properties are added after the first save() that caused the validation exception.

    You can use the SQL CREATE VERTEX statement: https://docs.arcadedb.com/#SQL-Create-Vertex.

    Example:

    CREATE VERTEX ChipID SET name = 'a', uid = 'b'
    
  3. lvca
    added
    questionFurther information is requested
    documentationImprovements or additions to documentation
    on Dec 19, 2022
  4. lvca
    added this to the 22.12.1 milestone on Dec 19, 2022
  5. lvca commented on Dec 19, 2022

    @lvca
    lvca
    on Dec 19, 2022
    Member
    More actions

    Alternatively you could try Gremlin addV() by setting properties immediately (the trick is passing the vertex type as label):

    g.addV('label', 'ChipID', 'name', 'a', 'uid', 'b');
    

    I've not tested it, but it's available in the Java API, so if the Gremlin driver is able to map that call, it should work.

  6. docbacardi commented on Dec 20, 2022

    @docbacardi
    docbacardi
    on Dec 20, 2022
    ContributorAuthor
    More actions

    The SQL CREATE VERTEX command works, thank you.

    testdatabase=> CREATE VERTEX ChipID SET name = 'a', uid = 'b';
     name | uid 
    ------+-----
     a    | b
    (1 row)
    
    INSERT 0 1
    

    The Gremlin command does not work:

    testdatabase=> {gremlin} g.addV('label', 'ChipID', 'name', 'a', 'uid', 'b');
    ERROR:  Syntax error on executing query: groovy.lang.MissingMethodException: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.addV() is applicable for argument types: (String, String, String, String, String, String) values: [label, ChipID, name, a, uid, b]
    Possible solutions: addV(), any(), wait(), call(), tx(), grep()
    

    It would be great to have a Gremlin solution for this.

  7. lvca commented on Dec 20, 2022

    @lvca
    lvca
    on Dec 20, 2022
    Member
    More actions

    That's Gremlin standard and it's out of our scope. I'm going to try to ask in the Gremlin Discord channel if this is an option. If yes, I could quickly submit a PR for that.

  8. lvca commented on Dec 21, 2022

    @lvca
    lvca
    on Dec 21, 2022
    Member
    More actions

    Gremlin team wrote back:

    "When you have the pattern of addV().property().property()... TinkerPop attempts to fold those property() calls back into addV() or more specifically into the AddVertexStep or AddVertexStartStep so that Graph.addVertex(...) can be called with all the property keys at once with the label. That addV().property(Map) overload kelvin was mentioning should behave in the same fashion. The vertex/edge will not be created all at once if there were some intermediate step between the addV() and the property()"

    Please let me know if the suggested way works for you, and I'll add it to the documentation.

  9. docbacardi commented on Dec 22, 2022

    @docbacardi
    docbacardi
    on Dec 22, 2022
    ContributorAuthor
    More actions

    I have to admit that I am not sure how to test this. Maybe you can give me a hint.

    While plain SQL works, Gremlin in studio, console and through Postgres does not work.
    The Gremlin team mentions tinkerpop, so I tried gremlin-cli, gdotv and gremlin-python. I failed to open a connection in gremlin-cli, most likely because I'm a complete beginner. gdotv and gremlin-python worked and I was able to access the database "graph". Unfortunately I did not manage to run SQL commands like "create property" on the "graph" database. Maybe this is issue #662 .
    I'm still working on connecting to other databases with gdotv and gremlin-python.

  10. docbacardi commented on Dec 22, 2022

    @docbacardi
    docbacardi
    on Dec 22, 2022
    ContributorAuthor
    More actions

    I just managed to connect to my testdatabase with gdotv and gremlin-python. Same result for both.
    Python:

    >>> g.addV('ChipID').property('name', 'x').property('uid', 'y').iterate()
    
    Received error message '{'requestId': 'f0138397-64d1-45f6-94e8-b8b8e6561c69', 'status': {'code': 500, 'message': "The property 'name' is mandatory, but not found on document: @ChipID[uid=y]", 'attributes': {'stackTrace': "com.arcadedb.exception.ValidationException: The property 'name' is mandatory, but not found on document: @ChipID[uid=y]\n\tat com.arcadedb.database.DocumentValidator.throwValidationExc...
    

    gdotv:

    g.addV('ChipID').property('name', 'x').property('uid', 'y').iterate()
    
    javax.script.ScriptException: java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: The property 'name' is mandatory, but not found on document: @ChipID[uid=y] 
    
  11. lvca commented on Dec 22, 2022

    @lvca
    lvca
    on Dec 22, 2022
    Member
    More actions

    Ok, I was able to intercept the API and override the set of properties with a call to .save() only after all properties are set. The fix should be pushed in <1h.

  12. lvca
    added a commit that references this issue on Dec 22, 2022

    fix: gremlin set of properties now is executed all in once to be comp…

    f5903b3
  13. lvca commented on Dec 22, 2022

    @lvca
    lvca
    on Dec 22, 2022
    Member
    More actions

    Ok, this is done. Thanks @docbacardi now constraints work with Gremlin too :-) Please let me know if you're able to run your queries now against latest snapshot taken from the main branch. We should release tomorrow 22.12.1...

  14. lvca
    closed this as completedon Dec 22, 2022
  15. lvca
    added
    bug
    bug fixed
    and removed
    documentationImprovements or additions to documentation
    questionFurther information is requested
    on Dec 22, 2022
  16. docbacardi commented on Dec 23, 2022

    @docbacardi
    docbacardi
    on Dec 23, 2022
    ContributorAuthor
    More actions

    Everything is working as expected, thank you very much for the fast help.

    Reacted by Luca Garulli
    Reacted by Luca Garulli
  17. lvca
    changed the title [-]Run gremlin graph methods like "addVertex" through Postgres driver[/-] [+]Support validation with Gremlin "addVertex" through Postgres driver[/+] on Dec 23, 2022
  18. mergify
    added a commit that references this issue on Dec 1, 2025

    chore(deps): bump dorny/test-reporter from 2.2.0 to 2.3.0 [skip ci]

    30b61d4
  19. mergify
    added a commit that references this issue on Feb 8, 2026

    chore(deps-dev): bump org.codehaus.mojo:license-maven-plugin from 2.4…

    e83f28e
  20. tae898
    added 3 commits that reference this issue on Jun 28, 2026

    fix: gremlin set of properties now is executed all in once to be comp…

    66bcc4a

    chore(deps): bump dorny/test-reporter from 2.2.0 to 2.3.0 [skip ci]

    ddc3273

    chore(deps-dev): bump org.codehaus.mojo:license-maven-plugin from 2.4…

    5aeb5a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lvca
    lvca

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    • 22.12.1

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.