{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "546718cb-adb2-421f-a415-6c4735c6cadc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e6b71dd7a7d844ce800e908a70115b4a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/html": [],
      "text/plain": [
       "MagicsControllerWidget(children=(Tab(children=(ManageSessionWidget(children=(HTML(value='<br/>'), HTML(value='…"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%reload_ext sparkmagic.magics\n",
    "%manage_spark"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2efcc1c4-3f94-43dd-b799-8c92d954f6dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FloatProgress(value=0.0, bar_style='info', description='Progress:', layout=Layout(height='25px', width='50%'),…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-----------------+\n",
      "|               Pi|\n",
      "+-----------------+\n",
      "|3.141592653589793|\n",
      "+-----------------+"
     ]
    }
   ],
   "source": [
    "%%spark\n",
    "import pyspark.sql.functions as F\n",
    "from pyspark.sql import SparkSession\n",
    "\n",
    "# Initialize a Spark session\n",
    "spark = SparkSession.builder.appName(\"PiValue\").getOrCreate()\n",
    "\n",
    "# Select and display the value of Pi\n",
    "spark.range(1).select(F.pi().alias(\"Pi\")).show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "12011df0-a540-4c13-bc78-a35cf4595c6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FloatProgress(value=0.0, bar_style='info', description='Progress:', layout=Layout(height='25px', width='50%'),…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "An error was encountered:\n",
      "<console>:1: error: illegal start of definition\n",
      "       # Initialize a Spark session\n",
      "       ^\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# Initialize a Spark session\n",
    "spark = SparkSession.builder.appName(\"PiValue\").getOrCreate()\n",
    "\n",
    "# Select and display the value of Pi\n",
    "spark.range(1).select(F.pi().alias(\"Pi\")).show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56291e89-4c3b-4c0e-9c78-8452490d2a63",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "PySpark",
   "language": "python",
   "name": "pysparkkernel"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "python",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "pyspark",
   "pygments_lexer": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
