Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add SQLServer transform flow #1089

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)