Skip to content

Commit

Permalink
Add field starting with digit test
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhanunlu committed Sep 13, 2024
1 parent 0900170 commit bb288a0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"self": {
"vendor": "myvendor",
"name": "digit",
"format": "jsonschema",
"version": "1-0-0"
},
"type": "object",
"properties": {
"1col_a": {"type": "string"}
},
"required": ["1col_a"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NonAtomicFieldsSpec extends Specification with CatsEffect {
return a merged schema if the batch uses all schemas in a series $ue3
return nothing for the Iglu Central ad_break_end_event schema $ue4
return a JSON field for the Iglu Central anything-a schema $ue5
return a field prefixed with underscore if field starts with a digit $ueDigit

when resolving for known schemas in contexts should
return an un-merged schema if the batch uses the first schema in a series $c1
Expand Down Expand Up @@ -197,6 +198,37 @@ class NonAtomicFieldsSpec extends Specification with CatsEffect {

}

def ueDigit = {
val tabledEntity = TabledEntity(TabledEntity.UnstructEvent, "myvendor", "digit", 1)

val input = Map(
tabledEntity -> Set((0, 0))
)

val expected = {
val expectedStruct = Type.Struct(
NonEmptyVector.of(
Field("_1col_a", Type.String, Required).copy(accessors = Set("1col_a"))
)
)

val expectedField = Field("unstruct_event_myvendor_digit_1", expectedStruct, Nullable, Set.empty)

TypedTabledEntity(
tabledEntity,
expectedField,
Set((0, 0)),
Nil
)
}

NonAtomicFields.resolveTypes(embeddedResolver, input, List.empty).map { case NonAtomicFields.Result(fields, failures) =>
(failures must beEmpty) and
(fields must haveSize(1)) and
(fields.head must beEqualTo(expected))
}
}

def c1 = {

val tabledEntity = TabledEntity(TabledEntity.Context, "myvendor", "myschema", 7)
Expand Down

0 comments on commit bb288a0

Please sign in to comment.