Skip to content

Complete SExI SQL assessment with pytest coverage - #88

Open
bogdanalexb wants to merge 1 commit into
sbms4d:qa_testfrom
bogdanalexb:solution/qa-test
Open

Complete SExI SQL assessment with pytest coverage#88
bogdanalexb wants to merge 1 commit into
sbms4d:qa_testfrom
bogdanalexb:solution/qa-test

Conversation

@bogdanalexb

Copy link
Copy Markdown

Summary

  • Rebuild the EMPLOYEE, EXPENSE, SUPPLIER, and INVOICE tables from the supplied source files with exact Trino types and rerunnable loaders.
  • Add deterministic reports for manager cycles, largest expense offenders, and supplier payment plans.
  • Add isolated pytest coverage for the required expense report, source-data quality, manager-cycle output, and payment-plan behavior.
  • Document the interpretations, rounding policy, expected results, run commands, and known limitations.

Key design decisions

  • Treat the single exployee_id occurrence as a typo because the CSV and downstream requirements consistently use employee_id.
  • Preserve the required invoice_ammount spelling.
  • Omit receipt and invoice descriptions because the required destination schemas do not provide description columns.
  • Calculate invoice due dates from Trino's current_date and run validation in UTC.
  • Return one deterministic loop per actual cycle member and exclude employees whose manager chain only feeds into a cycle.
  • Interpret an invoice due in N months as N month-end payments at offsets 0 through N - 1.
  • Allocate residual cents to the earliest instalments, keeping payments within one cent and reconciling every invoice exactly.
  • Aggregate supplier instalments by month before calculating balances with explicit window frames.

Testing and validation

  • Trino: 483
  • Image: trinodb/trino@sha256:db58cc93e593a2706553745f276bb119c9810e69918be56ecde088ba7ccb0534
  • Executed all six submitted SQL files through Trino CLI standard input.
  • Ran every loader twice to confirm rerunnable behavior.
  • Ran python -m pip check: no broken requirements.
  • Ran python -m pytest -q: 8 passed.
  • Ran the state-mutating report tests individually and in both explicit orders.
  • Confirmed mutation controls fail for an inclusive >= 1000.00 threshold and for a missing SQL file.
  • Repeated the full SQL and pytest workflow from a fresh clone in a path containing spaces; Git status remained clean.

Performance and limitations

  • Expense facts are aggregated before employee and manager joins.
  • Supplier names are deduplicated before ROW_NUMBER() assigns IDs.
  • Recursive traversal carries the next manager directly, requiring one hierarchy join per step; the supplied hierarchy is bounded to five steps.
  • Payment instalments are grouped once before total and cumulative windows are evaluated.
  • Dates remain intentionally relative to the Trino session date.
  • The Memory connector is ephemeral, and the serial tests reset shared memory.default state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant