From 45be6f9ee86f6fccf1c7a3641faae28ac4f64c03 Mon Sep 17 00:00:00 2001 From: Vijay Kiran Date: Wed, 11 May 2022 13:45:14 +0200 Subject: [PATCH] Add option to pass warehouse_name to execute (#112) Fixes #101 --- src/sodaspark/scan.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/sodaspark/scan.py b/src/sodaspark/scan.py index 529fb1b..efd0993 100644 --- a/src/sodaspark/scan.py +++ b/src/sodaspark/scan.py @@ -233,18 +233,18 @@ 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 @@ -252,6 +252,7 @@ def create_warehouse() -> Warehouse: def create_scan( scan_yml: ScanYml, variables: dict | None = None, + warehouse_name: str = "sodaspark", soda_server_client: SodaServerClient | None = None, ) -> Scan: """ @@ -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, @@ -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: @@ -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()