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

The diffChangeLog command doesn't work for Snowflake functions #5753

Closed
1 of 2 tasks
LonwoLonwo opened this issue Apr 2, 2024 · 8 comments
Closed
1 of 2 tasks

The diffChangeLog command doesn't work for Snowflake functions #5753

LonwoLonwo opened this issue Apr 2, 2024 · 8 comments

Comments

@LonwoLonwo
Copy link
Contributor

LonwoLonwo commented Apr 2, 2024

Search first

  • I searched and no similar issues were found

Description

I have two schemas in my Snowflake database. These schemas contain functions. I have the Liquibase license key and use it during the diffChangeLog command generation. And my generation process throws this error:

Caused by: java.lang.NullPointerException: Cannot invoke "String.equalsIgnoreCase(String)" because the return value of "liquibase.structure.core.StoredDatabaseLogic.getName()" is null
	at liquibase.structure.core.StoredDatabaseLogic.equals(StoredDatabaseLogic.java:79)
	at java.base/java.util.HashMap.putVal(Unknown Source)
	at java.base/java.util.HashMap.put(Unknown Source)
	at java.base/java.util.HashSet.add(Unknown Source)
	at liquibase.structure.DatabaseObjectCollection.add(DatabaseObjectCollection.java:83)
	at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:329)
	at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:456)
	at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:478)
	at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:369)
	at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:332)
	at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:106)
	at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:59)
	at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:34)
	at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:215)
	at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:188)

As I can see in the code base - only Snowflake Procedures comparing is supported.

You have already all logic for procedures, you can create the copy for functions, The FUNCTIONS view as very close to PROCEDURES view.

Steps To Reproduce

Create schema TEST1.
And create schema TEST2.

Add simple functions in schema TEST1, like

CREATE FUNCTION pi_udf()
  RETURNS FLOAT
  AS '3.141592654::FLOAT';

CREATE FUNCTION TEST1.simple_table_function()
  RETURNS TABLE (x INTEGER, y INTEGER)
  AS
  $$
    SELECT 1, 2
    UNION ALL
    SELECT 3, 4
  $$
  ;

Enable the diffChangeLog command for these two schemas (use TEST1 as a target).
Error occurs.

Expected/Desired Behavior

Result with one create function query.

Liquibase Version

4.26

Database Vendor & Version

Snowflake

Liquibase Integration

No response

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

Windows

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@filipelautert
Copy link
Collaborator

Hello @LonwoLonwo ! Thanks for the issue. In fact the Function code is in liquibase-commercial that's why you can't find it. But anyway this is a bug in commercial code that when comparing the objects is generating a null structure for the non-existent function in the destination database - thus generating the null pointer.

@filipelautert
Copy link
Collaborator

@LonwoLonwo This fix is on commercial, but I guess you can't see it: https://github.com/liquibase/liquibase-pro/pull/1638
Once I get an artifact I'll share the link.

@filipelautert filipelautert self-assigned this Apr 2, 2024
@LonwoLonwo
Copy link
Contributor Author

Thank you @filipelautert!

@filipelautert
Copy link
Collaborator

Hello @LonwoLonwo ! Are you able to give current master artifacts a try and see if it fixes the issue? https://github.com/liquibase/liquibase/actions/runs/8568825281/artifacts/1388234226 (from https://github.com/liquibase/liquibase/actions/runs/8568825281 run)

@LonwoLonwo
Copy link
Contributor Author

Hello @filipelautert

I'm sorry for not getting back to you sooner. I don't know how exactly I can use artifact files.
Maybe I will wait for the next release?

@filipelautert
Copy link
Collaborator

Hello @filipelautert

I'm sorry for not getting back to you sooner. I don't know how exactly I can use artifact files. Maybe I will wait for the next release?

@LonwoLonwo no problems!

@filipelautert
Copy link
Collaborator

@LonwoLonwo I'll close this one as the fix in merged to master. We are planning to release next week so you'll be able to test, but if the problem persists please reopen this one.

@LonwoLonwo
Copy link
Contributor Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants