Skip to content

Commit 150757d

Browse files
Add reflection support for new data types (#107)
* Add reflection support for new data types Add snapshot reflection support for the following databricks data types: -- Float -- Double -- Bool * chore(sonar): fix sonar warnings --------- Co-authored-by: filipe <flautert@liquibase.org>
1 parent 855da70 commit 150757d

File tree

6 files changed

+141
-4
lines changed

6 files changed

+141
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.liquibase.ext</groupId>
77
<artifactId>liquibase-databricks</artifactId>
8-
<version>1.1.2-SNAPSHOT</version>
8+
<version>1.1.3-SNAPSHOT</version>
99

1010
<name>Liquibase Extension: Databricks support</name>
1111
<description>Liquibase Extension for Databricks.</description>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package liquibase.ext.databricks.datatype;
2+
3+
import liquibase.change.core.LoadDataChange;
4+
import liquibase.database.Database;
5+
import liquibase.datatype.DataTypeInfo;
6+
import liquibase.datatype.DatabaseDataType;
7+
import liquibase.datatype.LiquibaseDataType;
8+
import liquibase.ext.databricks.database.DatabricksDatabase;
9+
import liquibase.servicelocator.PrioritizedService;
10+
11+
@DataTypeInfo(
12+
name = "boolean",
13+
minParameters = 0,
14+
maxParameters = 0,
15+
priority = PrioritizedService.PRIORITY_DATABASE
16+
)
17+
public class BooleanDatatypeDatabricks extends LiquibaseDataType {
18+
19+
public BooleanDatatypeDatabricks() {
20+
// empty constructor
21+
}
22+
23+
@Override
24+
public boolean supports(Database database) {
25+
return database instanceof DatabricksDatabase;
26+
}
27+
28+
@Override
29+
public DatabaseDataType toDatabaseDataType(Database database) {
30+
if (database instanceof DatabricksDatabase) {
31+
32+
DatabaseDataType type = new DatabaseDataType("BOOLEAN", this.getParameters());
33+
type.setType("BOOLEAN");
34+
return type;
35+
} else {
36+
return super.toDatabaseDataType(database);
37+
}
38+
39+
}
40+
41+
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
42+
return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN;
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package liquibase.ext.databricks.datatype;
2+
3+
import liquibase.change.core.LoadDataChange;
4+
import liquibase.database.Database;
5+
import liquibase.datatype.DataTypeInfo;
6+
import liquibase.datatype.DatabaseDataType;
7+
import liquibase.datatype.LiquibaseDataType;
8+
import liquibase.ext.databricks.database.DatabricksDatabase;
9+
import liquibase.servicelocator.PrioritizedService;
10+
11+
@DataTypeInfo(
12+
name = "double",
13+
minParameters = 0,
14+
maxParameters = 0,
15+
priority = PrioritizedService.PRIORITY_DATABASE
16+
)
17+
public class DoubleDatatypeDatabricks extends LiquibaseDataType {
18+
19+
public DoubleDatatypeDatabricks() {
20+
// empty constructor
21+
}
22+
23+
@Override
24+
public boolean supports(Database database) {
25+
return database instanceof DatabricksDatabase;
26+
}
27+
28+
@Override
29+
public DatabaseDataType toDatabaseDataType(Database database) {
30+
if (database instanceof DatabricksDatabase) {
31+
32+
DatabaseDataType type = new DatabaseDataType("DOUBLE", this.getParameters());
33+
type.setType("DOUBLE");
34+
return type;
35+
} else {
36+
return super.toDatabaseDataType(database);
37+
}
38+
39+
}
40+
41+
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
42+
return LoadDataChange.LOAD_DATA_TYPE.NUMERIC;
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package liquibase.ext.databricks.datatype;
2+
3+
import liquibase.change.core.LoadDataChange;
4+
import liquibase.database.Database;
5+
import liquibase.datatype.DataTypeInfo;
6+
import liquibase.datatype.DatabaseDataType;
7+
import liquibase.datatype.LiquibaseDataType;
8+
import liquibase.ext.databricks.database.DatabricksDatabase;
9+
import liquibase.servicelocator.PrioritizedService;
10+
11+
12+
@DataTypeInfo(
13+
name = "float",
14+
minParameters = 0,
15+
maxParameters = 0,
16+
priority = PrioritizedService.PRIORITY_DATABASE
17+
)
18+
public class FloatDatatypeDatabricks extends LiquibaseDataType {
19+
public FloatDatatypeDatabricks() {
20+
// empty constructor
21+
}
22+
23+
@Override
24+
public boolean supports(Database database) {
25+
return database instanceof DatabricksDatabase;
26+
}
27+
28+
@Override
29+
public DatabaseDataType toDatabaseDataType(Database database) {
30+
if (database instanceof DatabricksDatabase) {
31+
32+
DatabaseDataType type = new DatabaseDataType("FLOAT", this.getParameters());
33+
type.setType("FLOAT");
34+
return type;
35+
} else {
36+
return super.toDatabaseDataType(database);
37+
}
38+
39+
}
40+
41+
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
42+
return LoadDataChange.LOAD_DATA_TYPE.NUMERIC;
43+
}
44+
}

src/main/java/liquibase/ext/databricks/datatype/IntegerDatatypeDatabricks.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,26 @@
66
import liquibase.datatype.DatabaseDataType;
77
import liquibase.datatype.LiquibaseDataType;
88
import liquibase.ext.databricks.database.DatabricksDatabase;
9-
10-
import static liquibase.ext.databricks.database.DatabricksDatabase.PRIORITY_DATABASE;
9+
import liquibase.servicelocator.PrioritizedService;
1110

1211

1312
@DataTypeInfo(
1413
name = "int",
1514
minParameters = 0,
1615
maxParameters = 0,
17-
priority = PRIORITY_DATABASE
16+
priority = PrioritizedService.PRIORITY_DATABASE
1817
)
1918
public class IntegerDatatypeDatabricks extends LiquibaseDataType {
2019
public IntegerDatatypeDatabricks() {
20+
// empty constructor
2121
}
2222

23+
@Override
2324
public boolean supports(Database database) {
2425
return database instanceof DatabricksDatabase;
2526
}
2627

28+
@Override
2729
public DatabaseDataType toDatabaseDataType(Database database) {
2830
if (database instanceof DatabricksDatabase) {
2931

src/main/resources/META-INF/services/liquibase.datatype.LiquibaseDataType

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ liquibase.ext.databricks.datatype.DatetimeDatatypeDatabricks
22
liquibase.ext.databricks.datatype.BigintDatatypeDatabricks
33
liquibase.ext.databricks.datatype.StringDatatypeDatabricks
44
liquibase.ext.databricks.datatype.IntegerDatatypeDatabricks
5+
liquibase.ext.databricks.datatype.BooleanDatatypeDatabricks
6+
liquibase.ext.databricks.datatype.FloatDatatypeDatabricks
7+
liquibase.ext.databricks.datatype.DoubleDatatypeDatabricks

0 commit comments

Comments
 (0)