-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As of this commit, the avro support is almost complete. Missing: - duration type. I'd like to think about it a little more before doing this - we don't carry over to schema types some metadata (like precision/scale)
- Loading branch information
Showing
28 changed files
with
925 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"namespace": "io.typestream.testing.avro", | ||
"type": "record", | ||
"name": "SmokeType", | ||
"fields": [ | ||
{"name": "booleanField", "type": "boolean"}, | ||
{"name": "doubleField", "type": "double"}, | ||
{"name": "floatField", "type": "float"}, | ||
{"name": "intField", "type": "int"}, | ||
{"name": "longField", "type": "long"}, | ||
{"name": "stringField", "type": "string"}, | ||
|
||
{"name": "arrayField", "type": {"type": "array", "items": "string"}}, | ||
{"name": "enumField", "type": {"type": "enum", "name": "Color", "symbols": ["RED", "GREEN", "BLUE"]}}, | ||
{"name": "mapField", "type": {"type": "map", "values": "string"}}, | ||
{"name": "recordField", "type": { | ||
"type": "record", | ||
"name": "NestedRecord", | ||
"fields": [ | ||
{"name": "nestedInt", "type": "int"}, | ||
{"name": "nestedString", "type": "string"} | ||
] | ||
}}, | ||
|
||
{"name": "dateField", "type": {"type": "int", "logicalType": "date"}}, | ||
{"name": "decimalField", "type": {"type": "bytes", "logicalType": "decimal", "precision": 9, "scale": 2}}, | ||
{"name": "localTimestampMicrosField", "type": {"type": "long", "logicalType": "local-timestamp-micros"}}, | ||
{"name": "localTimestampMillisField", "type": {"type": "long", "logicalType": "local-timestamp-millis"}}, | ||
{"name": "timeMicrosField", "type": {"type": "long", "logicalType": "time-micros"}}, | ||
{"name": "timeMillisField", "type": {"type": "int", "logicalType": "time-millis"}}, | ||
{"name": "timestampMicrosField", "type": {"type": "long", "logicalType": "timestamp-micros"}}, | ||
{"name": "timestampMillisField", "type": {"type": "long", "logicalType": "timestamp-millis"}}, | ||
{"name": "uuidField", "type": {"type": "string", "logicalType": "uuid"}}, | ||
|
||
{"name": "optionalField", "type": ["null", "string"], "default": null} | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
libs/testing/src/main/kotlin/io/typestream/testing/model/SmokeType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.typestream.testing.model | ||
|
||
import io.typestream.testing.avro.Color | ||
import io.typestream.testing.avro.NestedRecord | ||
import java.time.Instant | ||
import java.time.LocalDate | ||
import java.time.LocalTime | ||
import java.time.ZoneId | ||
import java.util.UUID | ||
import io.typestream.testing.avro.SmokeType as AvroSmokeType | ||
|
||
data class SmokeType(override val id: String = "42") : TestRecord { | ||
override fun toAvro(): AvroSmokeType { | ||
val instant = Instant.ofEpochMilli(1576226562000L) | ||
val localDate = LocalDate.ofInstant(instant, ZoneId.systemDefault()) | ||
val localTime = LocalTime.ofInstant(instant, ZoneId.systemDefault()) | ||
val localDateTime = localTime.atDate(localDate) | ||
|
||
return AvroSmokeType.newBuilder() | ||
.setBooleanField(true) | ||
.setDoubleField(1.0) | ||
.setFloatField(2.0f) | ||
.setIntField(3) | ||
.setLongField(4L) | ||
.setStringField("5") | ||
.setArrayField(listOf("a", "b", "c")) | ||
.setEnumField(Color.RED) | ||
.setMapField(mapOf("key" to "value")) | ||
.setRecordField(NestedRecord.newBuilder().setNestedInt(11).setNestedString("12").build()) | ||
.setDateField(localDate) | ||
.setDecimalField("13.00".toBigDecimal()) | ||
.setLocalTimestampMicrosField(localDateTime) | ||
.setLocalTimestampMillisField(localDateTime) | ||
.setTimeMicrosField(localTime) | ||
.setTimeMillisField(localTime) | ||
.setTimestampMicrosField(instant) | ||
.setTimestampMillisField(instant) | ||
.setUuidField(UUID.fromString("2F5C4556-B5A1-45CE-AB36-DA41AEFF7E8D")) | ||
.setOptionalField("24") | ||
.build() | ||
} | ||
|
||
override fun toProto() = TODO() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.