Skip to content

Commit

Permalink
Add option to pass warehouse_name to execute (#112)
Browse files Browse the repository at this point in the history
Fixes #101
  • Loading branch information
vijaykiran authored May 11, 2022
1 parent 0a9f2b6 commit 45be6f9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/sodaspark/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,25 +233,26 @@ def create_scan_yml(scan_definition: str | Path) -> ScanYml:
return scan_yml


def create_warehouse_yml() -> WarehouseYml:
def create_warehouse_yml(warehouse_name: str = "sodaspark") -> WarehouseYml:
"""Create Spark a ware house yml."""
warehouse_yml = WarehouseYml(
name="sodaspark",
name=warehouse_name,
dialect=_SparkDialect(),
)
return warehouse_yml


def create_warehouse() -> Warehouse:
def create_warehouse(warehouse_name: str = "spdaspark") -> Warehouse:
"""Create a ware house."""
warehouse_yml = create_warehouse_yml()
warehouse_yml = create_warehouse_yml(warehouse_name)
warehouse = Warehouse(warehouse_yml)
return warehouse


def create_scan(
scan_yml: ScanYml,
variables: dict | None = None,
warehouse_name: str = "sodaspark",
soda_server_client: SodaServerClient | None = None,
) -> Scan:
"""
Expand All @@ -270,7 +271,7 @@ def create_scan(
out : Scan
The scan.
"""
warehouse = create_warehouse()
warehouse = create_warehouse(warehouse_name)
scan = Scan(
warehouse=warehouse,
scan_yml=scan_yml,
Expand Down Expand Up @@ -418,6 +419,7 @@ def execute(
df: DataFrame,
*,
variables: dict | None = None,
warehouse_name: str = "sodaspark",
soda_server_client: SodaServerClient | None = None,
as_frames: bool | None = False,
) -> ScanResult:
Expand Down Expand Up @@ -446,7 +448,10 @@ def execute(
df.createOrReplaceTempView(scan_yml.table_name)

scan = create_scan(
scan_yml, variables=variables, soda_server_client=soda_server_client
scan_yml,
variables=variables,
soda_server_client=soda_server_client,
warehouse_name=warehouse_name,
)
scan.execute()

Expand Down

0 comments on commit 45be6f9

Please sign in to comment.