Skip to content

Commit

Permalink
Add support for Avro records (#5)
Browse files Browse the repository at this point in the history
* Add publish configuration for Maven Central releases

* Allow Scala Tests action to be manually triggered (#2)

Signed-off-by: Dr. Daniel Alexander Smith <[email protected]>

* add avro support for RecordValue object (#1)

* add avro support for RecordValue object

Signed-off-by: Dr. Daniel Alexander Smith <[email protected]>

* use avro version that doesnt conflict with jackson

---------

Signed-off-by: Dr. Daniel Alexander Smith <[email protected]>
Co-authored-by: Dr. Daniel Alexander Smith <[email protected]>

* Bump to v1.1.0

Signed-off-by: Dr. Daniel Alexander Smith <[email protected]>

* Create CODEOWNERS

Signed-off-by: Dr. Daniel Alexander Smith <[email protected]>

---------

Signed-off-by: Dr. Daniel Alexander Smith <[email protected]>
Co-authored-by: Edward-Jones-6point6 <[email protected]>
  • Loading branch information
danielsmith-eu and Edward-Jones-6point6 authored Sep 1, 2023
1 parent c1284a6 commit d9104b6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @danielsmith-eu
1 change: 1 addition & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
name: Scala CI - Run Tests

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
Expand Down
19 changes: 6 additions & 13 deletions data-quality-profiler/build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ThisBuild / organization := "uk.gov.ipt.das"
ThisBuild / version := "1.0.0"
ThisBuild / organization := "io.github.6point6"
ThisBuild / version := "1.1.0"

name := "das-data-profiler"
name := "data-quality-profiler-and-rules-engine"

scalaVersion := "2.12.15"

Expand Down Expand Up @@ -63,6 +63,9 @@ libraryDependencies += "com.itextpdf" % "html2pdf" % "4.0.3"
// https://mvnrepository.com/artifact/com.github.spullara.mustache.java/compiler
libraryDependencies += "com.github.spullara.mustache.java" % "compiler" % "0.9.10"

//avro support
libraryDependencies += "org.apache.avro" % "avro" % "1.11.1"


Test / parallelExecution := true

Expand All @@ -81,16 +84,6 @@ addArtifact(artifact in (Compile, assembly), assembly)
/***/


publishTo := Some(s"GitHub Apache Maven Packages" at s"https://maven.pkg.github.com/${System.getenv("GITHUB_REPOSITORY")}")
credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
System.getenv("GITHUB_REPOSITORY_OWNER"),
System.getenv("GITHUB_TOKEN")
)
publishMavenStyle := true
isSnapshot := true

// these are all to allow local publishing to overwrite the version
publishConfiguration := publishConfiguration.value.withOverwrite(true)
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
Expand Down
35 changes: 35 additions & 0 deletions data-quality-profiler/publish.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ThisBuild / organization := "io.github.6point6"
ThisBuild / organizationName := "6point6"
ThisBuild / organizationHomepage := Some(url("https://6point6.co.uk/"))

ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/6point6/data-quality-profiler-and-rules-engine"),
"scm:[email protected]:6point6/data-quality-profiler-and-rules-engine.git"
)
)
ThisBuild / developers := List(
Developer(
id = "danielsmith-eu",
name = "Dr. Daniel Alexander Smith",
email = "[email protected]",
url = url("http://danielsmith.eu")
)
)

ThisBuild / description := "Data Quality Profiler and Rules Engine."
ThisBuild / licenses := List(
"MIT" -> new URL("https://opensource.org/license/mit/")
)
ThisBuild / homepage := Some(url("https://github.com/6point6/data-quality-profiler-and-rules-engine"))

// Remove all additional repository other than Maven Central from POM
ThisBuild / pomIncludeRepository := { _ => false }
ThisBuild / publishTo := {
// For accounts created after Feb 2021:
val nexus = "https://s01.oss.sonatype.org/"
//val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
ThisBuild / publishMavenStyle := true
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ object RecordValue {
case v: java.util.LinkedHashMap[String, Any] => ProfilableRecord.fromLinkedHashMap(linkedHashMap = v)
case v: java.math.BigDecimal => DoubleValue(v.doubleValue()) // TODO do better, write tests against this
case v: java.util.ArrayList[_] => ArrayValue(v.asScala.map{ RecordValue.fromAny })
case v: org.apache.avro.util.Utf8 => StringValue(v.toString)
case foo =>
throw new Exception(s"Unknown primtive type of in RecordValue.fromPrimitive: $foo, class: ${foo.getClass}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class ValuesTests extends AnyFunSpec {

}

it("should return a string for a avro record value") {
val testValue = RecordValue.fromAny( new org.apache.avro.util.Utf8("foo"))
assertResult(testValue.asString)("foo")
}

}

}

0 comments on commit d9104b6

Please sign in to comment.