Skip to content

[codex] Add workflow SQL parsing and separate DDL create flow#20

Merged
jruszo merged 4 commits intomasterfrom
feature/workflow-file-parse-ddl-create
Apr 2, 2026
Merged

[codex] Add workflow SQL parsing and separate DDL create flow#20
jruszo merged 4 commits intomasterfrom
feature/workflow-file-parse-ddl-create

Conversation

@jruszo
Copy link
Copy Markdown
Owner

@jruszo jruszo commented Apr 2, 2026

Summary

Add separate SPA create flows for DDL and DML workflows, introduce shared workflow-create UI logic, and add a workflow SQL parse endpoint for DML .sql uploads.

What Changed

  • add POST /api/v1/workflow/parse/ to split SQL text into statements and classify workflow syntax
  • enrich workflow submission metadata with per-instance allowed_syntax_types
  • add a shared SPA workflow creation view plus a new dedicated DDL route
  • update the DML create page to parse uploaded .sql files, reject mixed syntax uploads, and load parsed statements into the editor
  • reject LOAD DATA statements for workflow parsing, SQL check, and final workflow submission
  • update workflow list actions to expose separate DDL and DML create entry points

Why

The SPA only exposed a DML-specific create screen even though the workflow backend already supported both DDL and DML. It also lacked the legacy-style SQL file parsing flow needed for data update batches. This change restores file parsing for DML uploads, adds a dedicated DDL create path, and closes the gap where LOAD DATA statements could be treated as normal DML submissions even though the platform does not stage or manage external data files.

Impact

Users can now start DDL and DML workflows from separate SPA routes, DML uploads can be parsed and reviewed before submission, and unsupported LOAD DATA tasks are blocked consistently in both the SPA and legacy submit flows.

Validation

  • black --check .
  • npm run build in frontend/
  • docker exec datamingle-app python manage.py test sql_api.tests.TestWorkflow
  • docker exec datamingle-app python manage.py makemigrations sql --check

Summary by CodeRabbit

  • New Features

    • Separate creation paths for DDL and DML workflow requests
    • SQL file upload parsing with statement validation
    • Workflow content and rollback retrieval endpoints
    • Enhanced workflow filtering by scope (mine, pending review)
    • Improved submission metadata with syntax type information
  • Bug Fixes

    • Added validation to block LOAD DATA statements in workflow submissions

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 2, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 196ca364-3cab-494d-bee9-3ee33a4f13d0

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb072a and 0c216f4.

📒 Files selected for processing (10)
  • frontend/src/lib/api.ts
  • frontend/src/router/index.ts
  • frontend/src/views/DdlWorkflowCreateView.vue
  • frontend/src/views/DmlWorkflowCreateView.vue
  • frontend/src/views/WorkflowCreateView.vue
  • frontend/src/views/WorkflowsView.vue
  • sql_api/api_workflow.py
  • sql_api/serializers.py
  • sql_api/tests.py
  • sql_api/urls.py

📝 Walkthrough

Walkthrough

This pull request restructures the workflow submission system by introducing SQL parsing validation, DDL/DML separation, and new API endpoints. The frontend API layer is refactored with updated type signatures and three new endpoints (parse, content, rollback). A new WorkflowCreateView component serves as the reusable creation form, parameterized by syntax type and used by DDL and DML workflow variants. Backend validation adds LOAD DATA statement blocking and syntax-type classification per instance. Workflow filtering expands to include scope parameters (mine, pending_review).

Changes

Cohort / File(s) Summary
Frontend API Layer
frontend/src/lib/api.ts
Complete refactor of workflow types and functions: replaced WorkflowCheckPayload with WorkflowCheckRequest, added parsing types (WorkflowParseRequest, WorkflowParsedStatementRecord, WorkflowParseSummary, WorkflowParseResult), added WorkflowContentRecord and WorkflowRollbackRecord, updated WorkflowListFilters with scope field and empty-string support, added parseWorkflowSql(), fetchWorkflowContent(), fetchWorkflowRollback() functions, updated execution/window endpoints with new type signatures.
Frontend Routing & Views Setup
frontend/src/router/index.ts, frontend/src/views/DdlWorkflowCreateView.vue
Added /workflows/ddl/new route mapped to DdlWorkflowCreateView, which wraps WorkflowCreateView with expected-syntax-type="1" prop. Removed legacy /workflows/new route.
Frontend Workflow Creation
frontend/src/views/WorkflowCreateView.vue, frontend/src/views/DmlWorkflowCreateView.vue
Introduced new shared WorkflowCreateView component (860 lines) handling full creation flow with SQL parsing/checking, file upload, approval preview, and form validation. Refactored DmlWorkflowCreateView from full implementation (673 lines) to thin wrapper calling WorkflowCreateView with expected-syntax-type="2" and enable-file-parse="true".
Frontend Workflow List
frontend/src/views/WorkflowsView.vue
Updated metadata API wiring from fetchWorkflowMetadata to fetchWorkflowSubmissionMetadata, split single submit permission into dual canCreateDdl/canCreateDml capabilities based on instance allowed_syntax_types, refactored instance filtering on group_ids, converted syntaxType to numeric constraint `1
Backend API Endpoints & Validation
sql_api/api_workflow.py
Added three new API views (WorkflowParse, WorkflowContentDetail, WorkflowRollbackDetail), integrated SQL parsing with syntax classification (get_syntax_type, _classify_statement_syntax), added LOAD DATA statement blocking via regex validation, extended submission scoping for DDL access, added workflow list filtering by scope (mine, pending_review), computed allowed_syntax_types per instance and conditional group lists.
Backend Serializers
sql_api/serializers.py
Added four new DRF serializers for workflow parsing (WorkflowParseSerializer, WorkflowParsedStatementSerializer, WorkflowParseSummarySerializer, WorkflowParseResultSerializer), added LOAD_DATA_PATTERN regex constant, updated WorkflowContentSerializer.create() to validate and reject workflows containing LOAD DATA statements.
Backend URL Routing
sql_api/urls.py
Added three new routes: v1/workflow/parse/WorkflowParse.as_view(), v1/workflow/<int:workflow_id>/content/WorkflowContentDetail.as_view(), v1/workflow/<int:workflow_id>/rollback/WorkflowRollbackDetail.as_view().
Backend Test Coverage
sql_api/tests.py
Added comprehensive test suite covering workflow list scope filtering (pending_review, mine), submission metadata API with instance access levels, SQL parsing with syntax detection, mixed-syntax validation, LOAD DATA rejection, approval preview with temporary grants, workflow rollback content, and SQL check/submission LOAD DATA validation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend as WorkflowCreateView
    participant API as Backend API
    participant Engine as SQL Engine

    User->>Frontend: Upload/paste SQL
    Frontend->>API: POST /v1/workflow/parse/
    API->>Engine: generate_sql(sql_text)
    Engine-->>API: statements[]
    API->>API: Classify syntax_type per statement
    API->>API: Detect mixed/unknown syntax
    API-->>Frontend: WorkflowParseResult{statements[], summary}
    Frontend->>Frontend: Validate syntax_type matches expectedSyntaxType
    Frontend->>Frontend: Reject if LOAD DATA detected
    Frontend-->>User: Display parsed statements or error
Loading
sequenceDiagram
    participant User
    participant Frontend as WorkflowCreateView
    participant API as Backend API
    participant DB as Database

    User->>Frontend: Fill form, check SQL
    Frontend->>API: POST /v1/workflow/check/
    API->>API: Validate LOAD DATA pattern
    API->>DB: Execute check query
    DB-->>API: Check result{syntax_type, rows, status}
    API-->>Frontend: WorkflowCheckResult
    Frontend->>Frontend: Store check state & syntax_type
    User->>Frontend: Submit workflow
    Frontend->>Frontend: Verify check is current & matches expectedSyntaxType
    alt Check stale or mismatch
        Frontend->>API: POST /v1/workflow/check/ (re-run)
        API-->>Frontend: Updated result
    end
    Frontend->>API: POST /v1/workflow/create/
    API->>DB: Create workflow record
    DB-->>API: workflow{id, ...}
    API-->>Frontend: WorkflowCreateResult
    Frontend->>Frontend: Navigate to workflow-detail route
    Frontend-->>User: Show confirmation & redirect
Loading
sequenceDiagram
    participant User
    participant Frontend as WorkflowsView
    participant API as Backend API
    participant DB as Database

    User->>Frontend: Load workflow list with scope filter
    alt scope === 'mine'
        Frontend->>API: GET /v1/workflow/?scope=mine
        API->>DB: Filter by engineer == user
    else scope === 'pending_review'
        Frontend->>API: GET /v1/workflow/?scope=pending_review
        API->>DB: Filter by pending_review_workflow_ids(user)
    else scope === 'all'
        Frontend->>API: GET /v1/workflow/
        API->>DB: No scope filter
    end
    DB-->>API: workflows[]
    API-->>Frontend: List with metadataInstanceAccessLevel[]
    Frontend->>Frontend: Derive canCreateDdl/canCreateDml from allowed_syntax_types
    Frontend-->>User: Render workflows list + action buttons
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 SQL parsed with care, split by line,
DDL and DML both align!
Workflows created, checked, and reviewed,
A parsing hop through your chosen mood. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/workflow-file-parse-ddl-create

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

jruszo added 3 commits April 2, 2026 11:36
…le-parse-ddl-create

# Conflicts:
#	frontend/src/lib/api.ts
#	frontend/src/router/index.ts
#	frontend/src/views/WorkflowsView.vue
#	sql_api/api_workflow.py
#	sql_api/tests.py
@jruszo jruszo marked this pull request as ready for review April 2, 2026 10:51
@jruszo jruszo merged commit 722d1f5 into master Apr 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant