Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump schema-ddl to 0.25.0-M1 #89

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class TransformStructuredSpec extends Specification {
Field("my_string", Type.String, Required)
)

private val simpleOneFieldStartingWithDigitSchema =
NonEmptyVector.of(
Field("1my_string", Type.String, Required)
)

private val schemaWithAllPossibleTypes =
NonEmptyVector.of(
Field("my_string", Type.String, Required),
Expand Down Expand Up @@ -71,7 +76,9 @@ class TransformStructuredSpec extends Specification {
Successful transformation:
Valid event with only atomic fields (no custom entities) $onlyAtomic
Valid event with one custom context $oneContext
Valid event with one custom context starting with digit $oneContextDigit
Valid unstruct event $unstruct
Valid unstruct event with field starting with digit $unstructDigit
Valid event with two custom contexts, same major version $twoContextsSameMajor
Valid event with two custom contexts, different major version $twoContextsDifferentMajor
Valid event with each different type of atomic field $onlyAtomicAllTypes
Expand Down Expand Up @@ -120,6 +127,18 @@ class TransformStructuredSpec extends Specification {
assertSuccessful(inputEvent, batchInfo, expectedAllEntities = expectedOutput)
}

def unstructDigit = {
val inputEvent =
createEvent(unstruct = Some(sdj(data = json"""{ "1my_string": "abc"}""", key = "iglu:com.example/mySchema/jsonschema/1-0-0")))
val batchInfo = Result(
fields = Vector(mySchemaUnstruct(model = 1, subVersions = Set((0, 0)), simpleOneFieldStartingWithDigitSchema)),
igluFailures = List.empty
)
val expectedOutput = List(NamedValue(name = "unstruct_event_com_example_my_schema_1", value = json"""{ "_1my_string": "abc"}"""))

assertSuccessful(inputEvent, batchInfo, expectedAllEntities = expectedOutput)
}

def oneContext = {
val inputEvent =
createEvent(contexts = List(sdj(data = json"""{ "my_string": "abc"}""", key = "iglu:com.example/mySchema/jsonschema/1-0-0")))
Expand All @@ -134,6 +153,20 @@ class TransformStructuredSpec extends Specification {
assertSuccessful(inputEvent, batchInfo, expectedAllEntities = expectedOutput)
}

def oneContextDigit = {
val inputEvent =
createEvent(contexts = List(sdj(data = json"""{ "1my_string": "abc"}""", key = "iglu:com.example/mySchema/jsonschema/1-0-0")))
val batchInfo = Result(
fields = Vector(mySchemaContexts(model = 1, subVersions = Set((0, 0)), simpleOneFieldStartingWithDigitSchema)),
igluFailures = List.empty
)
val expectedOutput = List(
NamedValue(name = "contexts_com_example_my_schema_1", value = json"""[{ "_schema_version": "1-0-0", "_1my_string": "abc"}]""")
)

assertSuccessful(inputEvent, batchInfo, expectedAllEntities = expectedOutput)
}

def twoContextsDifferentMajor = {
val inputEvent = createEvent(contexts =
List(
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object Dependencies {
val azureSdk = "1.11.4"

// Snowplow
val schemaDdl = "0.23.0"
val schemaDdl = "0.25.0-M1"
val badrows = "2.3.0"
val igluClient = "3.2.0"
val tracker = "2.0.0"
Expand Down
Loading