Srinath Ganesh
Srinath Ganesh

Reputation: 2558

SQL like query language for Apache TinkerPop

Background: I have been using NEO4J and its Cypher Query till now and am looking to move to Apache TinkerPop to support multiple Graph DB.


In Cypher Query Language I to find my friends I would write this Query.

MATCH (you {name:"You"})-[:FRIEND]->(yourFriends)
RETURN you, yourFriends

Now I am looking for a Query Language similar to the one that is already coded in my code to work with Gremlin

from what I have looked, Gremlin has a script like "g.v(12).outE('knows').inV" but this is not similar to a SQL syntax, which is what I am looking for.

Note: I am NOT looking for SQL connectivity, I am just looking for a SQL LIKE Script

Upvotes: 1

Views: 713

Answers (1)

bechbd
bechbd

Reputation: 6341

TLDR;

The short answer to your question is that for Tinkerpop-enabled databases you will need to write your queries in Gremlin, there is not SQL-Like language currently.


Details

Gremlin differs from SQL and Cypher in multiple ways but a significant one being that Gremlin is a declarative language and SQL/Cypher are imperative languages. In Gremlin you define how you want to traverse through your graph and in SQL/Cypher you define what you want and the engine optimizes the traversal for you.

For example the Cypher query you have above would be written in Gremlin as:

g.V().has('name', 'You')
   .as('you').out('friend')
   .as('yourFriends')
   .select ('you', 'yourFriends')

Currently you would need to translate your Cypher queries to Gremlin to work against any number of TP databases including JanusGraph, CosmosDB, DSE Graph, AWS Neptune.... All the current providers can be found here: Tinkerpop Providers

Daniel Kuppitz has written a sight teaching you how to migrate from wiriting SQL Queries to writing gremlin ones and it is available here: SQL2Gremlin

Upvotes: 3

Related Questions