Skip to content
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

Support n-ary monotonic functions in discover_new_orderings #44

Open
wants to merge 7 commits into
base: apache_main
Choose a base branch
from

Conversation

gokselk
Copy link

@gokselk gokselk commented Nov 7, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@berkaysynnada
Copy link
Collaborator

I'm sorry for the delayed response @gokselk. I had to deal with some urgent maintenance issues. The refactor looks promising overall, but I noticed some issues in the tests that indicate potential bugs.

In your first test, the table is ordered as [a+b, a, b], and you add the equality c = a + b. This results in new orderings of [a+b] and [a, b]. I believe this is incorrect—you can find a simple counter-example if this isn’t immediately clear. The initial orderings should remain unchanged (or potentially be updated to [c, a, b] but this is not our concern).

The correct test case should be as follows: start with an initial ordering of [c, a, b], then add the equality c = a + b. The final orderings should then be [c] and [a, b]. I tested this scenario with your implementation, and it works as expected (it does not work without your refactor). However, the current test should not pass, as the implementation seems to perform unintended simplifications. You need to identify and address this bug.

Once that’s fixed, it would be beneficial to add more scenarios. Consider using ScalarFunctionExpr's as PhysicalExpr to represent different mathematical functions.

@berkaysynnada
Copy link
Collaborator

berkaysynnada commented Nov 13, 2024

You also need to resolve the conflicts coming from upstream to your branch.

@gokselk gokselk force-pushed the feature/support-n-ary-monotonic-fns branch from d631a11 to 04c1feb Compare November 19, 2024 06:48
@gokselk
Copy link
Author

gokselk commented Nov 21, 2024

In your first test, the table is ordered as [a+b, a, b], and you add the equality c = a + b. This results in new orderings of [a+b] and [a, b]. I believe this is incorrect—you can find a simple counter-example if this isn’t immediately clear. The initial orderings should remain unchanged (or potentially be updated to [c, a, b] but this is not our concern).

The correct test case should be as follows: start with an initial ordering of [c, a, b], then add the equality c = a + b. The final orderings should then be [c] and [a, b]. I tested this scenario with your implementation, and it works as expected (it does not work without your refactor). However, the current test should not pass, as the implementation seems to perform unintended simplifications. You need to identify and address this bug.

Thanks for catching this. I agree the original test case was incorrect. I'm debugging the unintended simplification behavior with the ordering [a+b, a, b]. Will update once I identify and fix the issue.

For now, I've updated the test to use the correct case: [c, a, b] -> [c] and [a, b].

@gokselk
Copy link
Author

gokselk commented Nov 22, 2024

@berkaysynnada I've pushed a potential fix that avoids unintended simplification by skipping cases where the original ordering starts with the equivalent expression.

However, I'm not entirely confident about this approach and would appreciate your review on whether this is the right way to handle these cases.

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

Successfully merging this pull request may close these issues.

2 participants