diff --git a/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java b/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java index 5e582e03..08e9b277 100644 --- a/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java +++ b/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java @@ -57,8 +57,10 @@ public void open(String url, Driver driverObject, Properties driverProperties) t driverProperties.setProperty("UserAgentEntry", "Liquibase"); // Set UserAgent to specify to Databricks that liquibase is the tool running these commands // Set EnableArrow because the arrow results break everything. And the JDBC release notes say to just disable it. - String updatedUrl = url + "UserAgentEntry=Liquibase;EnableArrow=0"; - this.openConn(updatedUrl, driverObject, driverProperties); + //String updatedUrl = url + "UserAgentEntry=Liquibase;EnableArrow=0"; + // This is done in getConnectionUrl() + + this.openConn(url, driverObject, driverProperties); } public void openConn(String url, Driver driverObject, Properties driverProperties) throws DatabaseException { @@ -143,8 +145,18 @@ public int getDatabaseMinorVersion() throws DatabaseException { /////////////////////////////////////////////////// copy from parent /////////////////////////////////////////////////// @Override protected String getConnectionUrl() throws SQLException { + String rawUrl = con.getMetaData().getURL(); - String updatedUrl = rawUrl + "UserAgentEntry=Liquibase;EnableArrow=0"; + // Check for ; characters + String updatedUrl; + + if (rawUrl.charAt(rawUrl.length() - 1) == ';') { + updatedUrl = rawUrl + "UserAgentEntry=Liquibase;EnableArrow=0;"; + } + else { + updatedUrl = rawUrl + ";UserAgentEntry=Liquibase;EnableArrow=0;"; + + } return updatedUrl; } diff --git a/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java b/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java index 65c45ea9..7bc8ec67 100644 --- a/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java +++ b/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java @@ -207,7 +207,7 @@ protected String getConnectionSchemaName() { try { String foundSchema = parseUrlForSchema(connection.getURL()); - System.out.println("SCHEMA IDENTIFIED: " + foundSchema); + Scope.getCurrentScope().getLog(getClass()).info("SCHEMA IDENTIFIED: " + foundSchema); return foundSchema; } catch (Exception e) { @@ -242,7 +242,7 @@ protected String getConnectionCatalogName() { try { String foundCatalog = parseUrlForCatalog(connection.getURL()); - System.out.println("CATALOG IDENTIFIED: " + foundCatalog); + Scope.getCurrentScope().getLog(getClass()).info("CATALOG IDENTIFIED: " + foundCatalog); return foundCatalog; diff --git a/src/test/resources/liquibase/harness/snapshot/expectedSnapshot/databricks/snapshotCaalogAndSchema.json b/src/test/resources/liquibase/harness/snapshot/expectedSnapshot/databricks/snapshotCaalogAndSchema.json index aca33a90..f9909b00 100644 --- a/src/test/resources/liquibase/harness/snapshot/expectedSnapshot/databricks/snapshotCaalogAndSchema.json +++ b/src/test/resources/liquibase/harness/snapshot/expectedSnapshot/databricks/snapshotCaalogAndSchema.json @@ -11,7 +11,7 @@ "liquibase.structure.core.Schema": [ { "schema": { - "name": "liquibase_test" + "name": "liquibase_harness_test_ds" } } ]