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 CREATE VIEW and CREATE TABLE verification #15195

Merged
merged 5 commits into from
Oct 6, 2020

Conversation

caithagoras
Copy link
Contributor

@caithagoras caithagoras commented Sep 21, 2020

Verify CREATE VIEW

If the specified view already exists, create a temporary view to match
the existing view. Otherwise, do nothing for setup queries. Rewrite the
target view name, and run both control and test queries. Run a SHOW
CREATE VIEW query and the returned CREATE VIEW statement needs to match.

Verify CREATE TABLE

Rewrite the target table of the CREATE TABLE statement, run both
control and test queries, run SHOW CREATE TABLE query as the check.

== RELEASE NOTES ==

Verifier Changes
* Add support to verify ``CREATE VIEW`` and ``CREATE TABLE`` queries.

@caithagoras caithagoras changed the title Support CREATE VIEW verification Support CREATE VIEW and CREATE TABLE verification Sep 21, 2020
@sujay-jain
Copy link
Member

started reviewing - first 3 commits LGTM

protected Optional<String> resolveFailure(Optional<QueryObjectBundle> control, Optional<QueryObjectBundle> test, QueryContext controlQueryContext, Optional<DdlMatchResult> matchResult, Optional<Throwable> throwable)
{
return Optional.empty();
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we not want a failureResolveManager like DataVerification?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Failure resolver is used to automatically resolve verification failures due to (test / checksum) query failures. For ddl verification, we can start with no auto resolution, and see if we actually see any query failures are actually false alerts.

// Otherwise, do not pre-create temporary view.
try {
CreateView createExistingView = (CreateView) sqlParser.createStatement(
getOnlyElement(prestoAction.execute(new ShowCreate(VIEW, createView.getName()), REWRITE, SHOW_CREATE_VIEW_CONVERTER).getResults()),
Copy link
Member

@sujay-jain sujay-jain Sep 30, 2020

Choose a reason for hiding this comment

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

Should we extract this into a method? Feel like it would be easier to follow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method would only be used once if we extract. I'm changing this to 2 statements - that might help readability.

Copy link
Member

@sujay-jain sujay-jain left a comment

Choose a reason for hiding this comment

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

LGTM

Remove unsupported query types in QueryType. Also, remove
QueryType.Category.
Repurpose the class to represent query bundle with any object name,
including table name and view name.
If either all the failure resolvers or all the failure resolver
factories are disabled, injection error would occurred due to
Set<FailureResolver> or Set<FailureResolverFactory> not binded.

Also, extract common logic of verification tests into an abstract
tests.
If the specified view already exists, create a temporary view to match
the existing view. Otherwise, do nothing for setup queries. Rewrite the
target view name, and run both control and test queries. Run a SHOW
CREATE VIEW query and the returned CREATE VIEW statement needs to match.
Rewrite the target table of the CREATE TABLE statement, run both
control and test queries, run SHOW CREATE TABLE query as the check.
@caithagoras
Copy link
Contributor Author

@sujay-jain Thanks for reviewing!

@caithagoras caithagoras merged commit 883e883 into prestodb:master Oct 6, 2020
@caithagoras caithagoras mentioned this pull request Oct 19, 2020
4 tasks
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.

None yet

3 participants