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
Read Snowflake views definitions with the Snowflake-specific query #3794
Read Snowflake views definitions with the Snowflake-specific query #3794
Conversation
Thanks for the fix and the good PR description. Mostly the PR is:
Correct? The NPE is being fixed by the fact that your new query should not be returning null definitions anymore? I'm wondering if a better structure to the changse are:
Think those changes would make it better, @LonwoLonwo ? |
Did you get a chance to see my comment above, @LonwoLonwo ? |
…s; avoid NPE from a view definition in the ViewSnapshotGenerator
Oh, sorry, @nvoxland for the late response. I missed the answer. Thanks for the reviewing and tips. Do I need to add any logging in case like this?: if (definition == null || definition.isEmpty()) {
return null;
} |
I don't have a strong opinion one way or the other. It probably wouldn't hurt to add debug-level logging there. It can help people troubleshoot what's going on, and that's always good. Just as long as it's not such a common scenario that it's not adding value for troubleshooting. |
Ok, logging added. I hope that the "info" level is enough. |
Initial/Pre-Review Thoughts Changes are looking good, thanks for the updates. Questions I have:
Potential risks:
What could make the full review difficult:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More ❄️ improvements, thanks!
...snowflake/src/main/java/liquibase/sqlgenerator/core/GetViewDefinitionGeneratorSnowflake.java
Show resolved
Hide resolved
@filipelautert and @LonwoLonwo, hello!
Also: nice to see you again, @LonwoLonwo! 👋🏻 Internal Functional Snowflake Test Suite Started Here --> [Snowflake functional test suite started here: https://github.com/liquibase/liquibase-pro-tests/actions/runs/4622799974. |
Nice to see you again @XDelphiGrl also Unfortunately, we could not reproduce the issue of our customer. Perhaps there were problems with the presence of permissions from the user or broken data. Therefore, it turns out that I added an explicit view definition reading for Snowflake and the processing of potential NPE handling. I apologize that I could not help anymore. |
@LonwoLonwo, I guessed that would be your answer. Your PRs always have excellent repro steps! I understand (and have experienced) being unable to replicate a bug that happens only in a customer environment. I'd be interested in hearing if this fixes their problem. I'm running our (internal) Snowflake functional test suite. This should at least tell us if there is something impacted by this change. I see some failures but I am 93% certain they are not due to this PR. We're having a week of strange build issues... I hope you have a lovely day! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR enhances the logic used by Liquibase to retrieve and generate Snowflake VIEW
definitions. It is anticipated that this fix addresses the null pointer mentioned in the description.
- Full set of Snowflake functional tests passing.
- Test harness execution passing.
- No additional testing required.
APPROVED
Thank you, @LonwoLonwo, for your patience as I worked through our test failure snafu. Your contributions are valued. Plus, I like working with you!
Impact
Description
Hello again! More enhancements for the Snowflake database, yes.
Now I would like to introduce you minor enhancement about the correct Snowflake view definitions reading.
Why did we do it? Because one of our users reported about NPE during the schema comparison in the Snowflake.
The error was here: https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/snapshot/jvm/ViewSnapshotGenerator.java#L86
A definition can be null in some side cases. AbstractJdbcDatabase#getViewDefinition can return
null
explicitly.Unfortunately, we could not reproduce this error. And decided to improve reading definitions for the Snowflake database at least. To increase the chances of the fact that the NPE will not happen again.
Example for view:
Things to worry about
CREATE_VIEW_AS_PATTERN has private status in the original class. Maybe getter will be better. But I just stole it.
And trimming of the ";" symbol looks not good, but this is what the definition from Snowflake looks like.