diff options
Diffstat (limited to 'examples/src/main/python/parquet_inputformat.py')
-rw-r--r-- | examples/src/main/python/parquet_inputformat.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/src/main/python/parquet_inputformat.py b/examples/src/main/python/parquet_inputformat.py index e1fd85b082..2f09f4d573 100644 --- a/examples/src/main/python/parquet_inputformat.py +++ b/examples/src/main/python/parquet_inputformat.py @@ -18,7 +18,7 @@ from __future__ import print_function import sys -from pyspark import SparkContext +from pyspark.sql import SparkSession """ Read data file users.parquet in local Spark distro: @@ -47,7 +47,13 @@ if __name__ == "__main__": exit(-1) path = sys.argv[1] - sc = SparkContext(appName="ParquetInputFormat") + + spark = SparkSession\ + .builder\ + .appName("ParquetInputFormat")\ + .getOrCreate() + + sc = spark._sc parquet_rdd = sc.newAPIHadoopFile( path, @@ -59,4 +65,4 @@ if __name__ == "__main__": for k in output: print(k) - sc.stop() + spark.stop() |