Skip to content

Fix Native Plan Checker for CTAS and Insert queries#25115

Merged
aditi-pandit merged 4 commits intoprestodb:masterfrom
tdcmeehan:validate_inserts
Jun 6, 2025
Merged

Fix Native Plan Checker for CTAS and Insert queries#25115
aditi-pandit merged 4 commits intoprestodb:masterfrom
tdcmeehan:validate_inserts

Conversation

@tdcmeehan
Copy link
Contributor

@tdcmeehan tdcmeehan commented May 14, 2025

Description

Currently writes are broken due to how the plan is presumed to be shaped by the C++ worker.

Motivation and Context

The sidecar should validate as many query shapes as possible for it to be effective.

Impact

Better validation by the sidecar.

Test Plan

Tests have been included.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== RELEASE NOTES ==

Prestissimo (Native Execution)
* Fix Native Plan Checker for CTAS and Insert queries

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label May 14, 2025
@tdcmeehan tdcmeehan force-pushed the validate_inserts branch 5 times, most recently from 5d3fc14 to d573908 Compare May 16, 2025 16:29
@tdcmeehan tdcmeehan changed the title Validate inserts Fix Native Plan Checker for CTAS and Insert queries May 16, 2025
@tdcmeehan tdcmeehan marked this pull request as ready for review May 16, 2025 20:20
@tdcmeehan tdcmeehan requested a review from ZacBlanco May 16, 2025 20:20
@prestodb-ci prestodb-ci requested review from a team, infvg and nmahadevuni and removed request for a team and ZacBlanco May 16, 2025 20:20
@tdcmeehan tdcmeehan requested a review from BryanCutler May 27, 2025 20:19
BryanCutler
BryanCutler previously approved these changes May 27, 2025
Copy link
Contributor

@BryanCutler BryanCutler left a comment

Choose a reason for hiding this comment

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

Looks better, thanks for the update to this!

runValidation(removeTableWriter(planFragment));
}

private SimplePlanFragment removeTableWriter(SimplePlanFragment planFragment)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be good to add a note as to why the TableWriterNode gets replaced

Copy link
Contributor

Choose a reason for hiding this comment

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

+1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, PTAL

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @tdcmeehan


// Launch distributed runner.
DistributedQueryRunner queryRunner = (DistributedQueryRunner) PrestoNativeQueryRunnerUtils.createQueryRunner(false, false, false, false);
DistributedQueryRunner queryRunner = (DistributedQueryRunner) PrestoNativeQueryRunnerUtils.createQueryRunner(false, false, false, false, ImmutableMap.of());
Copy link
Contributor

Choose a reason for hiding this comment

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

#25120 for QueryRunner with builders should soon be submit. Please refactor your code according to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done!

runValidation(removeTableWriter(planFragment));
}

private SimplePlanFragment removeTableWriter(SimplePlanFragment planFragment)
Copy link
Contributor

Choose a reason for hiding this comment

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

+1.

BryanCutler
BryanCutler previously approved these changes Jun 4, 2025
Copy link
Contributor

@BryanCutler BryanCutler left a comment

Choose a reason for hiding this comment

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

LGTM

aditi-pandit
aditi-pandit previously approved these changes Jun 5, 2025
Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks Tim.

@tdcmeehan tdcmeehan dismissed stale reviews from aditi-pandit and BryanCutler via 4843ba1 June 5, 2025 17:22
tdcmeehan added 4 commits June 5, 2025 14:11
Previously, these queries would always fail because the root of the plan
was TableWriterMerge.  Now, the plan is modified to swap out a dummy project
node for the TableWriterNode.  This is because TableWriterNode relies on
information that is not known until the scheduling phase.
Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @tdcmeehan

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

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants