Skip to content

Commit 85ee794

Browse files
committed
Add variable support in soda-spark
2 parents 09bb16c + dc8c69c commit 85ee794

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sodaspark/scan.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def create_warehouse() -> Warehouse:
250250

251251

252252
def create_scan(
253-
scan_yml: ScanYml, soda_server_client: SodaServerClient | None = None
253+
scan_yml: ScanYml, variables: dict = None, soda_server_client: SodaServerClient | None = None
254254
) -> Scan:
255255
"""
256256
Create a scan object.
@@ -259,6 +259,7 @@ def create_scan(
259259
----------
260260
scan_yml : ScanYml
261261
The scan yml.
262+
variables: variables to be substituted in scan yml
262263
soda_server_client : Optional[SodaServerClient] (default : None)
263264
A soda server client.
264265
@@ -272,6 +273,7 @@ def create_scan(
272273
warehouse=warehouse,
273274
scan_yml=scan_yml,
274275
soda_server_client=soda_server_client,
276+
variables=variables,
275277
time=dt.datetime.now(tz=dt.timezone.utc).isoformat(timespec="seconds"),
276278
)
277279
return scan
@@ -413,6 +415,7 @@ def execute(
413415
scan_definition: str | Path,
414416
df: DataFrame,
415417
*,
418+
variables: dict | None = None,
416419
soda_server_client: SodaServerClient | None = None,
417420
as_frames: bool | None = False,
418421
) -> ScanResult:
@@ -425,6 +428,8 @@ def execute(
425428
The path to a scan file or the content of a scan file.
426429
df: DataFrame
427430
The data frame to be scanned.
431+
variables: Optional[dict] (default : None)
432+
Variables to be substituted in scan yml
428433
soda_server_client : Optional[SodaServerClient] (default : None)
429434
A soda server client.
430435
as_frames : bool (default : False)
@@ -438,7 +443,7 @@ def execute(
438443
scan_yml = create_scan_yml(scan_definition)
439444
df.createOrReplaceTempView(scan_yml.table_name)
440445

441-
scan = create_scan(scan_yml, soda_server_client=soda_server_client)
446+
scan = create_scan(scan_yml, variables=variables, soda_server_client=soda_server_client)
442447
scan.execute()
443448

444449
if as_frames:

0 commit comments

Comments
 (0)