Skip to content

Commit

Permalink
fix: change priority method to ignore databases that are not databricks
Browse files Browse the repository at this point in the history
  • Loading branch information
filipelautert committed Jun 7, 2024
1 parent 6c369d0 commit 5ccabc7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public class ForeignKeySnapshotGeneratorDatabricks extends ForeignKeySnapshotGen
public static final String METADATA_DELETE_RULE = "DELETE_RULE";


@Override
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
if (database instanceof DatabricksDatabase) {
return super.getPriority(objectType, database) + PRIORITY_DATABASE;
} else {
return PRIORITY_NONE;
}
}

@Override
public Class<? extends SnapshotGenerator>[] replaces() {
return new Class[]{ForeignKeySnapshotGenerator.class};
Expand Down Expand Up @@ -289,4 +298,4 @@ private boolean driverUsesSpFkeys(Database database) throws DatabaseException {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import liquibase.database.Database;
import liquibase.exception.DatabaseException;
import liquibase.snapshot.CachedRow;
import liquibase.snapshot.DatabaseSnapshot;;
import liquibase.snapshot.DatabaseSnapshot;
import liquibase.structure.core.Schema;

import java.sql.SQLException;
import java.util.List;
import liquibase.ext.databricks.snapshot.jvm.ResultSetCacheDatabricks;

public class ResultSetConstraintsExtractorDatabricks extends ResultSetCacheDatabricks.SingleResultSetExtractor {

Expand Down Expand Up @@ -79,4 +78,4 @@ private String createSql(String catalog, String schema, String table) {

return sql;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class UniqueConstraintSnapshotGeneratorDatabricks extends UniqueConstrain

@Override
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
int priority = super.getPriority(objectType, database);
if (priority > PRIORITY_NONE && database instanceof DatabricksDatabase) {
priority += DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE;
if (database instanceof DatabricksDatabase) {
return super.getPriority(objectType, database) + PRIORITY_DATABASE;
} else {
return PRIORITY_NONE;
}
return priority;
}

@Override
Expand Down Expand Up @@ -62,4 +62,4 @@ protected List<CachedRow> listConstraints(Table table, DatabaseSnapshot snapshot
}

return Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database).queryForList(new RawSqlStatement(sql));
}}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class ViewSnapshotGeneratorDatabricks extends ViewSnapshotGenerator {

@Override
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
int priority = super.getPriority(objectType, database);
if (priority > PRIORITY_NONE && database instanceof DatabricksDatabase) {
priority += DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE;
if (database instanceof DatabricksDatabase) {
return super.getPriority(objectType, database) + PRIORITY_DATABASE;
} else {
return PRIORITY_NONE;
}
return priority;
}

@Override
Expand Down

0 comments on commit 5ccabc7

Please sign in to comment.