Skip to content

Commit

Permalink
Add support for serializing MapType (#929) (#939)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8efe1ec)

Signed-off-by: Chase Engelbrecht <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 12b8091 commit 5585f1a
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 5585f1a

Please sign in to comment.