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

Minor cleanups in SqlFormatter #9501

Merged
merged 1 commit into from
Oct 11, 2021
Merged

Conversation

losipiuk
Copy link
Member

@losipiuk losipiuk commented Oct 5, 2021

No description provided.

@martint
Copy link
Member

martint commented Oct 5, 2021

What’s the purpose of those assertions? Indent can’t be anything other than 0 already, since that’s how the visitor gets called in the first place, and it’s private to this class, so it can’t be misused.

@@ -1282,7 +1312,7 @@ private static String formatPrincipal(PrincipalSpecification principal)
}

@Override
protected Void visitDropTable(DropTable node, Integer context)
protected Void visitDropTable(DropTable node, Integer indent)
Copy link
Member

Choose a reason for hiding this comment

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

checkArgument? (and below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. Sequence of private methods fooled me. We are already past public interface.

@losipiuk
Copy link
Member Author

losipiuk commented Oct 6, 2021

What’s the purpose of those assertions? Indent can’t be anything other than 0 already, since that’s how the visitor gets called in the first place, and it’s private to this class, so it can’t be misused.

Just a sanity check. It is not obvious from the code flow that we can not land in the visitXXX method which ignores indent param as a result of calling out to process(currentNode.getSomething(), indent + 1).
If that would be the case we would end up with misformatted SQL - having an error is better IMO.

@losipiuk
Copy link
Member Author

I dropped checks as thy do play well with PREPARE ...

@losipiuk losipiuk merged commit 60eb474 into trinodb:master Oct 11, 2021
@github-actions github-actions bot added this to the 364 milestone Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants