From 1f6ba00542dc39b10a479a229e2deeef7f3c343d Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Tue, 23 Aug 2022 12:15:26 +0800 Subject: [PATCH] Added pyshell calling lines and python file header discussed in https://github.com/vesoft-inc/nebula-spark-connector/issues/50 Thanks to @Reid00 --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index c823db67..dad9b967 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,34 @@ df.write.format("com.vesoft.nebula.connector.NebulaDataSource").option( "user", "root").save() ``` +Also, below are examples on how we run above code with pyspark shell or in python code files: + +- Call with PySpark shell: + +```bash +/spark/bin/pyspark --driver-class-path nebula-spark-connector-3.0.0.jar --jars nebula-spark-connector-3.0.0.jar +``` + +- In Python code: + +``` +from pyspark.sql import SparkSession + +spark = SparkSession.builder.config( + "nebula-spark-connector-3.0.0.jar", + "/path_to/nebula-spark-connector-3.0.0.jar").appName( + "nebula-connector").getOrCreate() + +df = spark.read.format( + "com.vesoft.nebula.connector.NebulaDataSource").option( + "type", "vertex").option( + "spaceName", "basketballplayer").option( + "label", "player").option( + "returnCols", "name,age").option( + "metaAddress", "metad0:9559").option( + "partitionNumber", 1).load() +``` + ## Version match There are the version correspondence between Nebula Spark Connector and Nebula: