-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
12 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
from pyspark.sql import SparkSession | ||
|
||
def get_taxis(): | ||
spark = SparkSession.builder.getOrCreate() | ||
def get_taxis(spark: SparkSession): | ||
return spark.read.table("samples.nyctaxi.trips") | ||
|
||
def main(): | ||
get_taxis().show(5) | ||
get_taxis(spark).show(5) | ||
|
||
if __name__ == '__main__': | ||
main() |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
from databricks.connect import DatabricksSession | ||
from pyspark.sql import SparkSession | ||
from databricks.connect import DatabricksSession as SparkSession | ||
from default_python import main | ||
from pytest import fixture | ||
|
||
# Create a new Databricks Connect session. If this fails, | ||
# check that you have configured Databricks Connect correctly. | ||
# See https://docs.databricks.com/dev-tools/databricks-connect.html. | ||
|
||
SparkSession.builder = DatabricksSession.builder | ||
SparkSession.builder.getOrCreate() | ||
@fixture(scope="session") | ||
def spark(): | ||
return SparkSession.builder.getOrCreate() | ||
|
||
def test_main(): | ||
taxis = main.get_taxis() | ||
def test_main(spark): | ||
taxis = main.get_taxis(spark) | ||
assert taxis.count() > 5 |