-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RDB Shredder: factor out scala-common-enrich (close #138)
- Loading branch information
Showing
27 changed files
with
982 additions
and
1,130 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
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
32 changes: 0 additions & 32 deletions
32
shredder/src/main/scala/com.snowplowanalytics.snowplow.storage/package.scala
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
shredder/src/main/scala/com.snowplowanalytics.snowplow.storage/spark/BadRow.scala
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,47 @@ | ||
package com.snowplowanalytics.snowplow.storage.spark | ||
|
||
import io.circe.{Encoder, Json} | ||
import io.circe.syntax._ | ||
import cats.data.NonEmptyList | ||
import com.snowplowanalytics.iglu.client.ClientError | ||
import com.snowplowanalytics.iglu.core.SchemaKey | ||
import com.snowplowanalytics.snowplow.analytics.scalasdk.Event | ||
|
||
|
||
sealed trait BadRow { | ||
def toCompactJson: String | ||
} | ||
|
||
object BadRow { | ||
|
||
|
||
case class ShreddingError(original: String, errors: NonEmptyList[String]) extends BadRow { | ||
def toCompactJson: String = | ||
Json.obj( | ||
"original" := original.asJson, | ||
"errors" := errors.asJson | ||
).noSpaces | ||
} | ||
|
||
case class ValidationError(original: Event, errors: NonEmptyList[SchemaError]) extends BadRow { | ||
def toCompactJson: String = | ||
Json.obj( | ||
"original" := original.asJson, | ||
"errors" := errors.asJson | ||
).noSpaces | ||
} | ||
|
||
case class DeduplicationError(original: Event, error: String) extends BadRow { | ||
def toCompactJson: String = Json.obj( | ||
"original" := original.asJson, | ||
"error" := error.asJson | ||
).noSpaces | ||
} | ||
|
||
case class SchemaError(schema: SchemaKey, error: ClientError) | ||
|
||
implicit val schemaErrorCirceJsonEncoder: Encoder[SchemaError] = | ||
Encoder.instance { case SchemaError(schema, error) => | ||
error.asJson.deepMerge(Json.obj("schema" := schema.toSchemaUri.asJson)) | ||
} | ||
} |
Oops, something went wrong.