Skip to content

Fixing hybrid conversion bug that caused naming errors #283

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

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

knassre-bodo
Copy link
Contributor

The bug was brought to attention by cases like this:

urgent_orders = (
  customers.CALCULATE(nation_name=nation.name)
  .orders
  .WHERE(order_priority == "1-URGENT")
  .CALCULATE(nation_name, order_year=YEAR(order_date), order_month=MONTH(order_date))
)
groups = PARTITION(urgent_orders, name="u", by=(nation_name, order_year, order_month))
result = groups.CALCULATE(nation_name, order_year, order_month, n_orders=COUNT(u))

There is a name-resolution bug during hybrid conversion that causes nation_name to be incorrectly changed to nation_name_0 when used as a child reference to the data being partitioned, which causes a key error during relational conversion when it looks for $0.nation_name_0 in the expression dictionary but can't find it.

The fix is to avoid the invocation of nation_name in the second CALCULATE causing an extra renaming since it is just a re-invocation of the same term.

@knassre-bodo knassre-bodo requested a review from vineetg3 March 4, 2025 20:09
Copy link
Contributor

@vineetg3 vineetg3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. LGTM!

@knassre-bodo knassre-bodo merged commit 96f7d3d into main Mar 4, 2025
5 checks passed
@knassre-bodo knassre-bodo deleted the kian/fix_hybrid_bug branch March 4, 2025 23:42
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.

2 participants