Search code examples
cassandradatastax-enterprisedatastax-java-driverdatastax-enterprise-graph

Java DSE GraphFrame API does not fully support going from GraphTraversal to DataFrame


The Java DSE GraphFrame API does not fully support going from GraphTraversal to DataFrame.

The following GraphTraversal to DataFrame is possible:

gf().E().df()

However this does not:

gf().E().hasLabel("foo").df()

This is because hasLabel() returns a GraphTraversal instead of com.datastax.bdp.graph.spark.graphframe.DseGraphTraversal and GraphTraversal does not have the df() method.

This should be possible per the docs

To finish a traversal and return to the DataFrame API instead of list or iterator use the .df() method:

graph.V().df()

I'm using dse-graph-frames:5.1.4 along with dse-byos_2.11:5.1.4.

Is this expected? All I really want is to do some graph traversal and convert it into a DataFrame.


Solution

  • It works in Scala as is, in Java you need to add the cast to DseGraphTraversal

    ((DseGraphTraversal)gf.E().hasLabel("foo")).df()
    

    I gave a longer answer here Iterating a GraphTraversal with GraphFrame causes UnsupportedOperationException Row to Vertex conversion