Skip to content

Commit

Permalink
✨ Add SQLServer transform flow (#1089)
Browse files Browse the repository at this point in the history
* ✨ Add SQLServer transform flow

* 📝 Add SQLServer transform prefect flow

---------

Co-authored-by: angelika233 <[email protected]>
  • Loading branch information
angelika233 and angelika233 authored Oct 10, 2024
1 parent 27e158c commit 6ac2487
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/references/orchestration/prefect/flows.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@

::: viadot.orchestration.prefect.flows.sql_server_to_parquet

::: viadot.orchestration.prefect.flows.sql_server_transform

::: viadot.orchestration.prefect.flows.supermetrics_to_adls

::: viadot.orchestration.prefect.flows.transform
Expand Down
2 changes: 2 additions & 0 deletions src/viadot/orchestration/prefect/flows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .sharepoint_to_s3 import sharepoint_to_s3
from .sql_server_to_minio import sql_server_to_minio
from .sql_server_to_parquet import sql_server_to_parquet
from .sql_server_transform import sql_server_transform
from .supermetrics_to_adls import supermetrics_to_adls
from .transform import transform
from .transform_and_catalog import transform_and_catalog
Expand Down Expand Up @@ -67,6 +68,7 @@
"sharepoint_to_s3",
"sql_server_to_minio",
"sql_server_to_parquet",
"sql_server_transform",
"supermetrics_to_adls",
"transform",
"transform_and_catalog",
Expand Down
34 changes: 34 additions & 0 deletions src/viadot/orchestration/prefect/flows/sql_server_transform.py
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,
)

0 comments on commit 6ac2487

Please sign in to comment.