Skip to content

Commit

Permalink
Add support for serializing MapType (#929)
Browse files Browse the repository at this point in the history
Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas authored Nov 20, 2024
1 parent dc690b4 commit 8efe1ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ object FlintDataType {
// objects
case st: StructType => serializeJValue(st)

// Serialize maps as empty objects and let the map entries automap
case mt: MapType => serializeJValue(new StructType())

// array
case ArrayType(elementType, _) => serializeField(elementType, Metadata.empty)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ class FlintDataTypeSuite extends FlintSuite with Matchers {
|}""".stripMargin)
}

test("spark map type serialize") {
val sparkStructType = StructType(
StructField("mapField", MapType(StringType, StringType), true) ::
Nil)

FlintDataType.serialize(sparkStructType) shouldBe compactJson("""{
| "properties": {
| "mapField": {
| "properties": {
| }
| }
| }
|}""".stripMargin)
}

test("spark varchar and char type serialize") {
val flintDataType = """{
| "properties": {
Expand Down

0 comments on commit 8efe1ec

Please sign in to comment.