Skip to content

Commit

Permalink
Add support for serializing TimestampNTZType (#673)
Browse files Browse the repository at this point in the history
* Add support for TIMESTAMP_NTZ in FlintDataType

Signed-off-by: Chase Engelbrecht <[email protected]>

* Add unit test

Signed-off-by: Chase Engelbrecht <[email protected]>

---------

Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas authored Sep 19, 2024
1 parent 56c4c34 commit 7ff1512
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ object FlintDataType {
case FloatType => JObject("type" -> JString("float"))

// Date
case TimestampType =>
case TimestampType | _: TimestampNTZType =>
JObject(
"type" -> JString("date"),
"format" -> JString("strict_date_optional_time_nanos"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ class FlintDataTypeSuite extends FlintSuite with Matchers {
FlintDataType.serialize(sparkStructType) shouldBe compactJson(flintDataType)
}

test("flint timestamp_ntz serialize") {
val flintDataType = """{
| "properties": {
| "timestampField": {
| "type": "date",
| "format": "strict_date_optional_time_nanos"
| }
| }
|}""".stripMargin
val sparkStructType = StructType(
StructField("timestampField", TimestampNTZType, true) ::
Nil)
FlintDataType.serialize(sparkStructType) shouldBe compactJson(flintDataType)
}

test("spark array type map to should map to array element type in OpenSearch") {
val flintDataType = """{
| "properties": {
Expand Down

0 comments on commit 7ff1512

Please sign in to comment.