Querying DSE Graph vertices and edges with Spark SQL
Spark SQL can query DSE Graph vertex and edge tables.
The dse_graph database holds the vertex and edge tables for each graph.
The naming format for the tables is
<graph name>_vertices and
For example, if you have a graph named
gods, the vertices and edges are accessible in Spark SQL in the
select * from dse_graph.gods_vertices;
If you have properties that are spelled the same but with different capitalizations (for example,
Id), start Spark SQL with the
--conf spark.sql.caseSensitive=true option.
Start the Spark SQL shell.
Query the vertices and edges using
USE dse_graph; SELECT * FROM gods_vertices where name = 'Zeus';
Join the vertices and edges in a query.
Vertices are identified by
idcolumns. Edge tables have
dstcolumns that identify the from and to vertices, respectively. A join can be used to traverse the graph. For example to find all vertex ids that are reached by the out edges:
SELECT gods_edges.dst FROM gods_vertices JOIN gods_edges ON gods_vertices.id = gods_edges.src;