-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add SQLServer transform flow (#1089)
* ✨ Add SQLServer transform flow * 📝 Add SQLServer transform prefect flow --------- Co-authored-by: angelika233 <[email protected]>
- Loading branch information
1 parent
27e158c
commit 6ac2487
Showing
3 changed files
with
38 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
src/viadot/orchestration/prefect/flows/sql_server_transform.py
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Flow for transforming data inside the SQLServer.""" | ||
|
||
from prefect import flow | ||
|
||
from viadot.orchestration.prefect.tasks import sql_server_query | ||
|
||
|
||
@flow( | ||
name="transform--sql_server", | ||
description="Transform data inside the SQLServer.", | ||
retries=1, | ||
retry_delay_seconds=60, | ||
) | ||
def sql_server_transform( | ||
query: str, | ||
sql_server_credentials_secret: str | None = None, | ||
sql_server_config_key: str | None = None, | ||
) -> None: | ||
"""Run query inside the SQLServer. | ||
Args: | ||
query (str, required): The query to execute on the SQL Server database. | ||
If the qery doesn't start with "SELECT" returns an empty DataFrame. | ||
sql_server_credentials_secret (str, optional): The name of the secret storing | ||
the credentialsto the SQLServer. Defaults to None. | ||
More info on: https://docs.prefect.io/concepts/blocks/ | ||
sql_server_config_key (str, optional): The key in the viadot config | ||
holding relevant credentials to the SQLServer. Defaults to None. | ||
""" | ||
sql_server_query( | ||
query=query, | ||
config_key=sql_server_config_key, | ||
credentials_secret=sql_server_credentials_secret, | ||
) |