Skip to content

Conversation

@comphead
Copy link
Contributor

Which issue does this PR close?

Closes #3695.

Rationale for this change

skip_failing_rules default to true in tests so that regressions are caught much sooner

What changes are included in this PR?

Are there any user-facing changes?

@comphead
Copy link
Contributor Author

@andygrove please check this PR. I have commented out 1 test as it fails, will create another PR to fix the test

@github-actions github-actions bot added the core Core DataFusion crate label Oct 19, 2022
alamb
alamb previously approved these changes Oct 19, 2022
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @AssHero

My only concern about this approach is that now we are not testing the same thing that users are.

What would we feel about changing the default value of OPT_OPTIMIZER_SKIP_FAILED_RULES to always be true and downstream projects could turn it to true if they wanted.

What do you think @avantgardnerio ?

false,
),
#[cfg(test)]
ConfigDefinition::new_bool(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ConfigDefinition::new_bool(
// skip_failing_rules default to true in tests so that regressions are caught much sooner
ConfigDefinition::new_bool(

Comment on lines 243 to 245
"When set to true, the logical plan optimizer will produce warning \
messages if any optimization rules produce errors and then proceed to the next \
rule. When set to false, any rules that produce errors will cause the query to fail.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"When set to true, the logical plan optimizer will produce warning \
messages if any optimization rules produce errors and then proceed to the next \
rule. When set to false, any rules that produce errors will cause the query to fail.",
"OVERRIDDEN FOR TEST",

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could be very confusing to people (that tests and defaults are different) so I suggest some more comments to make it clearer

Ok(())
}

#[ignore]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a ticket to track this failure. How does it fail with the change in default?

@alamb alamb dismissed their stale review October 19, 2022 18:55

did not mean to approve -- I think we should default to true always

to reduce the number of rows decoded.",
false,
),
#[cfg(test)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this #[cfg(test)] will effectively only apply to tests in the datafusion/core crate -- this option will be false for other tests (like sql_integration for example)

@comphead
Copy link
Contributor Author

comphead commented Oct 19, 2022

Thanks @alamb for the feedback.
I'm not an @AssHero though :)
I like the idea to default to FALSE always, so we dont skip any unexpected behaviuor. For all failing tests, lets ignore them for now to avoid build fail, and I can create separate tickets for each failing test.

@andygrove
Copy link
Member

What would we feel about changing the default value of OPT_OPTIMIZER_SKIP_FAILED_RULES to always be true

I think that would be problematic given the current maturity of the optimization rules. It would result in many queries failing rather than just skipping some optimizations.

@alamb
Copy link
Contributor

alamb commented Oct 19, 2022

I'm not an @AssHero though :)

🤦 I apologize to both of you

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

I think tests should be explicit about the configs they are testing. I don't think we should have different default values for configs between test and production code.

@comphead
Copy link
Contributor Author

comphead commented Oct 19, 2022

I'm wondering what is the point of test that works with enabled skip_failing_rules, but will fail otherwise.....
Shouldn't be they just ignored and fixed later, as now it looks misleading a bit

@comphead
Copy link
Contributor Author

I think tests should be explicit about the configs they are testing. I don't think we should have different default values for configs between test and production code.

Sorry @andygrove, I lost a bit. So you also support disabling failing rules check, ignore tests, and create a new PR to fix them?

@andygrove
Copy link
Member

Currently, if any rule fails with an Err then the optimizer just skips that rule, so the user does not see an error and their query works (but maybe not fully optimized). I think this is the correct behavior for now because we know that there are bugs in some of the rules.

I would like to have regression tests to that we don't introduce any new bugs that cause rules to fail. One approach would be to set datafusion.optimizer.skip_failed_rules=false in all the tests where that does not cause a test failure, and make sure we have issues filed for tests that would fail with that setting and add a comment to those tests, linking to the issue.

Long term I would like the setting to default to false, but we need to fix the bugs first.

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates sql SQL Planner labels Oct 22, 2022
@comphead
Copy link
Contributor Author

@andygrove got your point thanks. Please check renewed PR

So idea is by default tests run with enabled skip_optimization_errors, to make them fail instead of warning, one can run tests specyfing the conf explicitly as cargo test --features "optimizer_failed_rules"

1 similar comment
@comphead
Copy link
Contributor Author

@andygrove got your point thanks. Please check renewed PR

So idea is by default tests run with enabled skip_optimization_errors, to make them fail instead of warning, one can run tests specyfing the conf explicitly as cargo test --features "optimizer_failed_rules"

@comphead
Copy link
Contributor Author

@andygrove please check until the code rots

@alamb
Copy link
Contributor

alamb commented Oct 27, 2022

Marking as a draft as it is waiting on review from @andygrove

@alamb alamb marked this pull request as draft October 27, 2022 14:27
@andygrove
Copy link
Member

@andygrove got your point thanks. Please check renewed PR

So idea is by default tests run with enabled skip_optimization_errors, to make them fail instead of warning, one can run tests specyfing the conf explicitly as cargo test --features "optimizer_failed_rules"

Hi @comphead. Apologies for the delay in reviewing. I'm not sure that we want to introduce feature flags for this. I was thinking that we could explicitly set datafusion.optimizer.skip_failed_rules in tests. The goal would be to eventually set this to false but for some tests we would need to leave it as true for now and then file issues for fixing those tests. Does that make sense?

@comphead
Copy link
Contributor Author

@andygrove got your point thanks. Please check renewed PR
So idea is by default tests run with enabled skip_optimization_errors, to make them fail instead of warning, one can run tests specyfing the conf explicitly as cargo test --features "optimizer_failed_rules"

Hi @comphead. Apologies for the delay in reviewing. I'm not sure that we want to introduce feature flags for this. I was thinking that we could explicitly set datafusion.optimizer.skip_failed_rules in tests. The goal would be to eventually set this to false but for some tests we would need to leave it as true for now and then file issues for fixing those tests. Does that make sense?

Thanks @andygrove for feedback.

Please correct me if I'm wrong.

  • We have specific test list that should be fixed later but now works not fully optimized, and we ok, therefore these tests require optimizer_skip_error as true. And this test list is known.
  • For all other tests(existing or new) optimizer_skip_error has to be false.

If thats correct, I will rework the PR

@andygrove
Copy link
Member

Now that #4208 is implemented, I suggest that we:

  • Update existing rules to implement try_optimize so that they return Ok(None) instead of Err when the rule does not support the plan (we should create one PR per rule)
  • Change the default value of datafusion.optimizer.skip_failed_rules to false, and fix any test failures

@comphead
Copy link
Contributor Author

  • Ok

Thanks for letting me know, checking this.

@comphead comphead closed this Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OptimizerConfig::skip_failing_rules should be false by default in sql tests

3 participants