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

fetch prev op source columns in get operation #526

Merged
merged 1 commit into from
Mar 29, 2024
Merged
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
23 changes: 23 additions & 0 deletions ddpui/api/transform_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
EditDbtOperationPayload,
)
from ddpui.core.transformfunctions import validate_operation_config
from ddpui.api.warehouse_api import get_warehouse_data

from ddpui.core import dbtautomation_service
from ddpui.core.dbtautomation_service import sync_sources_for_warehouse
Expand Down Expand Up @@ -357,12 +358,34 @@ def get_operation(request, operation_uuid: str):
if not dbt_operation:
raise HttpError(404, "operation not found")

prev_source_columns = []
if dbt_operation.seq > 1:
prev_dbt_op = OrgDbtOperation.objects.filter(
dbtmodel=dbt_operation.dbtmodel, seq=dbt_operation.seq - 1
).first()
prev_source_columns = prev_dbt_op.output_cols
else:
config = dbt_operation.config
if "input_models" in config and len(config["input_models"]) >= 1:
model = OrgDbtModel.objects.filter(
uuid=config["input_models"][0]["uuid"]
).first()
if model:
for col_data in get_warehouse_data(
request,
"table_columns",
schema_name=model.schema,
table_name=model.name,
):
prev_source_columns.append(col_data["name"])

return {
"id": dbt_operation.uuid,
"output_cols": dbt_operation.output_cols,
"config": dbt_operation.config,
"type": "operation_node",
"target_model_id": dbt_operation.dbtmodel.uuid,
"prev_source_columns": prev_source_columns,
}


Expand Down
Loading