Skip to content

Conversation

florianhysenii
Copy link

  • Defines the EMPLOYEE table using data from hr/employee_index.csv.

  • Inserts sample employee records.

  • Created create_expenses.sql:

    • Defines the EXPENSE table for storing last night's receipts.
    • Inserts expense data from the finance/receipts_from_last_night files.
    • Includes inline comments to explain the approach and optimizations.
  • Created create_invoices.sql:

    • Defines the INVOICE and SUPPLIER tables.
    • Inserts invoice data from the finance/invoices_due files.
    • Assigns supplier IDs (sorted alphabetically) and sets due dates as the last day of the month.
  • Created calculate_largest_expensors.sql:

    • Aggregates employee expenses to report those with a total expensed amount over 1000.
    • Joins EMPLOYEE and EXPENSE tables and retrieves manager names via a self-join.
  • Created find_manager_cycles.sql:

    • Implements a recursive CTE to detect cycles in the employee-manager relationships.
    • Returns each employee_id along with the detected loop (manager cycle) as a comma-separated list.
  • Created generate_supplier_payment_plans.sql:

    • Generates a monthly supplier payment plan using UNNEST and sequence to simulate monthly payments.
    • Calculates payment amounts, outstanding balances, and corresponding payment dates.
    • Avoids a recursive CTE to ensure compatibility with Trino.

  - Defines the EMPLOYEE table using data from hr/employee_index.csv.
  - Inserts sample employee records.

- Created create_expenses.sql:
  - Defines the EXPENSE table for storing last night's receipts.
  - Inserts expense data from the finance/receipts_from_last_night files.
  - Includes inline comments to explain the approach and optimizations.

- Created create_invoices.sql:
  - Defines the INVOICE and SUPPLIER tables.
  - Inserts invoice data from the finance/invoices_due files.
  - Assigns supplier IDs (sorted alphabetically) and sets due dates as the last day of the month.

- Created calculate_largest_expensors.sql:
  - Aggregates employee expenses to report those with a total expensed amount over 1000.
  - Joins EMPLOYEE and EXPENSE tables and retrieves manager names via a self-join.

- Created find_manager_cycles.sql:
  - Implements a recursive CTE to detect cycles in the employee-manager relationships.
  - Returns each employee_id along with the detected loop (manager cycle) as a comma-separated list.

- Created generate_supplier_payment_plans.sql:
  - Generates a monthly supplier payment plan using UNNEST and sequence to simulate monthly payments.
  - Calculates payment amounts, outstanding balances, and corresponding payment dates.
  - Avoids a recursive CTE to ensure compatibility with Trino.
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