How to export a Datastax graph based on a specific traversal using DseGraphFrame

70 Views Asked by At

I would like to export a DSE graph via a spark job , as per https://docs.datastax.com/en/dse/6.0/dse-dev/datastax_enterprise/graph/graphAnalytics/dseGraphFrameExport.html

All this works fine within the spark-shell , I want to be doing this in Java using DseGraphFrame . Unfortunately there is not much in the documentation

I am able to pack a jar with the following code and do a spark-submit

SparkSession spark = SparkSession
        .builder()
        .appName("Datastax Java example")
        .getOrCreate();
    DseGraphFrame dseGraphFrame = DseGraphFrameBuilder.dseGraph(args[0], spark);
    DataFrameWriter dataFrameWriter = dseGraphFrame.V().df().write();
    dataFrameWriter.csv("vertices");

The above works fine , what I want to be doing is use a specific traversal to filter what I export. That is use something like that

dseGraphFrame.V().hasLabel("label").df().write();

The above does not work as dseGraphFrame.V().hasLabel("label") does not have .df()

Is this the correct way of doing things

Any help would be appreciated

1

There are 1 best solutions below

0
On

A late answer to this question, perhaps still of use:

In Java, you need to cast this to a DseGraphTraversal first. This can then be converted to a DataFrame with the .df() method:

((DseGraphTraversal)dseGraphFrame.V().hasLabel("label")).df().write();