Skip to content

Add Dependency Checker for LogicalLocalPlanOptimizer #130409

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

julian-elastic
Copy link
Contributor

@julian-elastic julian-elastic commented Jul 1, 2025

Add verification for LocalLogical plan
The verification is skipped if there is remote enrich, similar to how it is skipped for LocalPhysical plan optimization

@julian-elastic julian-elastic changed the title Test Dependency Checker for LogicalLocalPlanOptimizer Add Dependency Checker for LogicalLocalPlanOptimizer Jul 3, 2025
@julian-elastic julian-elastic added >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL labels Jul 3, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @julian-elastic, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

Thanks @julian-elastic ! This is close.

I'd add a test that demonstrates that the verifier actually works so accidentally disabling it becomes noticeable in CI. Check out LogicalPlanOptimizerTests#testPlanSanityCheck - I think we need a similar test in the LocalLogicalPlanOptimizerTests. Also, I noticed that there is PhysicalPlanOptimizerTests#testVerifierOnMissingReferences but no corresponding test in LocalPhysicalPlanOptimizerTests - it'd be nice if we could fix that, although it's technically out of scope for this PR.

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

It'd be great to also add the justification for the change; i.e. what changes are now possible that the original check wouldn't catch (I guess triggered by folding a field missing locally). Noting it as we've been trying to shave planning costs.

Also, one check which would be great (since it caused at least two bugs), but not done atm. is verifying the the physical layout doesn't change (so somewhat related, but not directly). Just mentioning it as possible alternative.

@alex-spies
Copy link
Contributor

Also, one check which would be great (since it caused at least two bugs), but not done atm. is verifying the the physical layout doesn't change (so somewhat related, but not directly). Just mentioning it as possible alternative.

That's actually a very good idea for a follow-up. Pre- and post optimization, the local plan must have the same output; simplest would be to try and use the QueryPlan#output method for this check.

@bpintea
Copy link
Contributor

bpintea commented Jul 7, 2025

simplest would be to try and use the QueryPlan#output method for this check.

FWIW, what #129370 fixed wouldn't have been caught by verifying the outputs pre- and post-optimizations, since agg's outputs contain both aggs and groups (aliased or not). Only the layout changed because of a group being dropped. So we need a check of the layouts on both ends (coordinator and data node), which is tricker.

@julian-elastic
Copy link
Contributor Author

I created the follow up PR for the output checker here #130757

@julian-elastic julian-elastic requested a review from alex-spies July 7, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants