Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix: preserve Glue column parameters (#1210)

David Phillips94a8bdaca1b5
diff --git a/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats b/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats
index 9cf076d28b..6d51a81843 100644
--- a/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats
+++ b/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats
@@ -53,7 +53,10 @@ table_input() {
Columns: [
{
Name: "id",
- Type: "int"
+ Type: "int",
+ Parameters: {
+ comment: "identifier"
+ }
}
]
}
@@ -121,8 +124,10 @@ function_input() {
assert_success
name=$(json_get "$output" '.Table.Name')
version_id=$(json_get "$output" '.Table.VersionId')
+ column_comment=$(json_get "$output" '.Table.StorageDescriptor.Columns[0].Parameters.comment')
[ "$name" = "$TABLE_NAME" ]
[ "$version_id" = "0" ]
+ [ "$column_comment" = "identifier" ]
run aws_cmd glue get-tables --database-name "$DB_NAME"
assert_success
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java
index 9dc52e7b7a..e7c479649c 100644
--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java
@@ -126,6 +126,10 @@ class GlueCatalogTest {
assertThat(createdTable.databaseName()).isEqualTo(DATABASE_NAME);
assertThat(createdTable.name()).isEqualTo(TABLE_NAME);
assertThat(createdTable.versionId()).isEqualTo("0");
+ assertThat(createdTable.storageDescriptor().columns())
+ .singleElement()
+ .satisfies(column -> assertThat(column.parameters())
+ .containsEntry("comment", "identifier"));
assertThat(glue.getTables(GetTablesRequest.builder()
.databaseName(DATABASE_NAME)
.build()).tableList())
@@ -284,6 +288,7 @@ class GlueCatalogTest {
.columns(Column.builder()
.name("id")
.type("int")
+ .parameters(Map.of("comment", "identifier"))
.build())
.build())
.build();
diff --git a/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java b/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java
index 0ddee2b631..8ed1680d89 100644
--- a/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java
@@ -449,6 +449,7 @@ public class GlueService {
columnCopy.setName(column.getName());
columnCopy.setType(column.getType());
columnCopy.setComment(column.getComment());
+ columnCopy.setParameters(copyMap(column.getParameters()));
copy.add(columnCopy);
}
return copy;
diff --git a/src/main/java/io/github/hectorvent/floci/services/glue/model/Column.java b/src/main/java/io/github/hectorvent/floci/services/glue/model/Column.java
index 7f3f387195..bd02103c6e 100644
--- a/src/main/java/io/github/hectorvent/floci/services/glue/model/Column.java
+++ b/src/main/java/io/github/hectorvent/floci/services/glue/model/Column.java
@@ -3,6 +3,9 @@ package io.github.hectorvent.floci.services.glue.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
@RegisterForReflection
public class Column {
@JsonProperty("Name")
@@ -11,6 +14,8 @@ public class Column {
private String type;
@JsonProperty("Comment")
private String comment;
+ @JsonProperty("Parameters")
+ private Map<String, String> parameters;
public Column() {}
public Column(String name, String type) {
@@ -24,4 +29,6 @@ public class Column {
public void setType(String type) { this.type = type; }
public String getComment() { return comment; }
public void setComment(String comment) { this.comment = comment; }
+ public Map<String, String> getParameters() { return parameters == null ? null : new LinkedHashMap<>(parameters); }
+ public void setParameters(Map<String, String> parameters) { this.parameters = parameters == null ? null : new LinkedHashMap<>(parameters); }
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java
index be81ebf991..cfe0f92971 100644
--- a/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java
@@ -69,7 +69,9 @@ class GlueServiceTest {
Table table = new Table();
table.setName("plain");
StorageDescriptor sd = new StorageDescriptor();
- sd.setColumns(java.util.List.of(new Column("a", "string")));
+ Column column = new Column("a", "string");
+ column.setParameters(Map.of("trino_type_id", "varchar"));
+ sd.setColumns(java.util.List.of(column));
table.setStorageDescriptor(sd);
glueService.createTable("db1", table);
@@ -78,6 +80,7 @@ class GlueServiceTest {
assertEquals(1, fetched.getStorageDescriptor().getColumns().size());
assertEquals("a", fetched.getStorageDescriptor().getColumns().get(0).getName());
assertEquals("0", fetched.getVersionId());
+ assertEquals("varchar", fetched.getStorageDescriptor().getColumns().get(0).getParameters().get("trino_type_id"));
assertNull(fetched.getStorageDescriptor().getSchemaReference());
}