Exporting graphs using DseGraphFrame

Use DseGraphFrame to export the graph to any format supported by Spark.

  1. Start the Spark shell.

    $ dse spark
  2. Export the vertices and edges to a Spark-supported using the write method.

    Export the graph to JSON files in the DSEFS file system.

    val g = spark.dseGraph("gods_export")
    g.V.write.json("/tmp/v_json")
    g.E.write.json("/tmp/e_json")

    That will create two directories in the DSEFS file system with vertex and edge JSON files. You can get data locally if they are not too large for the local file system:

    $ dse fs "cat /tmp/v_json/* > file:/home/username/local_vertices.json" &&
    dse fs "cat /tmp/e_json/* > file:/home/username/local_edges.json"

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com