Skip to content

maximum recursion depth exceeded / $0.key_0 #557

Description

@juankx-bodo

PyDough code (without the max_recursion_depth_exceeded calculation) succeeds with pydough.explain_llm(), but fails with pydough.to_sql().

Error generating SQL:

  • maximum recursion depth exceeded
  • $0.key_0

Minimal reproducible example (TPCH):

# Step 1: Prepare order data with customer name and year
invoice_info = orders.CALCULATE(
    order_year=YEAR(order_date),
    key=customer.key,
    order_total=total_price
)

# Step 2: Partition by customer to calculate total per customer
customer_level = invoice_info.PARTITION(
    name="customer_groups", 
    by=(key)
).CALCULATE(
    max_recursion_depth_exceeded=SUM(invoice_info.order_total),
    key_0_error=SUM(orders.total_price)
)

Additional Context / Workarounds

Behavior Shift: Removing the max_recursion_depth_exceeded calculation produces a $0.key_0 error instead, and pydough.explain_llm() succeeds at this point.
Workaround: The bug can be prevented by changing key=customer.key to cust_id=customer.key in Step 1.

TPCH collections used:

  orders
  ├── order_date
  ├── total_price
  └── customer [one member of customers]

  customers
  ├── key
  └── orders [multiple orders]

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions