Created
April 26, 2019 02:28
-
-
Save yuvipanda/c1df43456edcecefc78cf0ba47c59c33 to your computer and use it in GitHub Desktop.
sample spark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from pyspark.sql import SparkSession\n", | |
"import os\n", | |
"app_name = \"wk12_demo\"\n", | |
"master = \"local[*]\"\n", | |
"ui_prefix = os.environ.get('JUPYTERHUB_SERVICE_PREFIX', '/') + 'sparkui'\n", | |
"\n", | |
"spark = SparkSession\\\n", | |
" .builder\\\n", | |
" .appName(app_name)\\\n", | |
" .master(master)\\\n", | |
" .config('spark.ui.proxyBase', ui_prefix)\\\n", | |
" .getOrCreate()\n", | |
"\n", | |
"sc = spark.sparkContext" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"1249975000" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"rdd = sc.parallelize(list(range(50000)))\n", | |
"rdd.sum()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment