File tree Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 11{
22 "cells" : [
3+ {
4+ "cell_type" : " code" ,
5+ "execution_count" : null ,
6+ "metadata" : {},
7+ "outputs" : [],
8+ "source" : [
9+ " %load_ext autoreload\n " ,
10+ " %autoreload 2"
11+ ]
12+ },
313 {
414 "cell_type" : " code" ,
515 "execution_count" : null ,
2131 " sys.path.append('../src')\n " ,
2232 " from default_python import main\n " ,
2333 " \n " ,
24- " main.get_taxis().show(10)"
34+ " main.get_taxis(spark ).show(10)"
2535 ]
2636 }
2737 ],
4151 "name" : " python3"
4252 },
4353 "language_info" : {
54+ "codemirror_mode" : {
55+ "name" : " ipython" ,
56+ "version" : 3
57+ },
58+ "file_extension" : " .py" ,
59+ "mimetype" : " text/x-python" ,
4460 "name" : " python" ,
45- "version" : " 3.11.4"
61+ "nbconvert_exporter" : " python" ,
62+ "pygments_lexer" : " ipython3" ,
63+ "version" : " 3.11.8"
4664 }
4765 },
4866 "nbformat" : 4 ,
Original file line number Diff line number Diff line change 11from pyspark .sql import SparkSession
22
3- def get_taxis (spark : SparkSession ):
3+ def get_taxis (spark : SparkSession ):
44 return spark .read .table ("samples.nyctaxi.trips" )
55
66def main ():
7+ from databricks .connect import DatabricksSession as SparkSession
8+ spark = SparkSession .builder .getOrCreate ()
79 get_taxis (spark ).show (5 )
810
911if __name__ == '__main__' :
Original file line number Diff line number Diff line change 7575 "name" : " python" ,
7676 "nbconvert_exporter" : " python" ,
7777 "pygments_lexer" : " ipython3" ,
78- "version" : " 3.11.6 "
78+ "version" : " 3.11.8 "
7979 }
8080 },
8181 "nbformat" : 4 ,
Original file line number Diff line number Diff line change 11from databricks .connect import DatabricksSession as SparkSession
2+ from pytest import fixture
23from default_python import main
34from pytest import fixture
45
5- # Create a new Databricks Connect session. If this fails,
6- # check that you have configured Databricks Connect correctly.
7- # See https://docs.databricks.com/dev-tools/databricks-connect.html.
8-
96@fixture (scope = "session" )
107def spark ():
11- return SparkSession .builder .getOrCreate ()
8+ spark = SparkSession .builder .getOrCreate ()
9+ yield spark
10+ spark .stop ()
11+
1212
13- def test_main (spark ):
13+ def test_main (spark : SparkSession ):
1414 taxis = main .get_taxis (spark )
1515 assert taxis .count () > 5
You can’t perform that action at this time.
0 commit comments