diff --git a/build.sbt b/build.sbt index 6fd5656f6..566afd4e0 100644 --- a/build.sbt +++ b/build.sbt @@ -120,8 +120,10 @@ lazy val datasource = project moduleName := "rasterframes-datasource", libraryDependencies ++= Seq( compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full), + compilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full), sttpCatsCe2, stac4s, + framelessRefined excludeAll ExclusionRule(organization = "com.github.mpilquist"), geotrellis("s3").value excludeAll ExclusionRule(organization = "com.github.mpilquist"), spark("core").value % Provided, spark("mllib").value % Provided, diff --git a/datasource/src/main/scala/org/locationtech/rasterframes/datasource/stac/api/encoders/StacSerializers.scala b/datasource/src/main/scala/org/locationtech/rasterframes/datasource/stac/api/encoders/StacSerializers.scala index 9f085a8c0..5a17a1019 100644 --- a/datasource/src/main/scala/org/locationtech/rasterframes/datasource/stac/api/encoders/StacSerializers.scala +++ b/datasource/src/main/scala/org/locationtech/rasterframes/datasource/stac/api/encoders/StacSerializers.scala @@ -8,10 +8,12 @@ import com.azavea.stac4s._ import com.azavea.stac4s.types.ItemDatetime import eu.timepit.refined.api.{RefType, Validate} import frameless.{Injection, SQLTimestamp, TypedEncoder, TypedExpressionEncoder} +import frameless.refined import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder import org.apache.spark.sql.jts.JTSTypes import java.time.Instant +import scala.reflect.ClassTag /** STAC API Dataframe relies on the Frameless Expressions derivation. */ trait StacSerializers { @@ -42,9 +44,12 @@ trait StacSerializers { implicit val itemDatetimeCatalystType: Injection[ItemDatetimeCatalystType, String] = Injection(_.repr, ItemDatetimeCatalystType.fromString) implicit val itemDatetimeInjection: Injection[ItemDatetime, ItemDatetimeCatalyst] = Injection(ItemDatetimeCatalyst.fromItemDatetime, ItemDatetimeCatalyst.toDatetime) - /** Refined types support, https://github.com/typelevel/frameless/issues/257#issuecomment-914392485 */ - implicit def refinedInjection[F[_, _], T, P](implicit refType: RefType[F], validate: Validate[T, P]): Injection[F[T, P], T] = - Injection(refType.unwrap, value => refType.refine[P](value).valueOr(errMsg => throw new IllegalArgumentException(s"Value $value does not satisfy refinement predicate: $errMsg"))) + /** Refined types support, proxies to avoid frameless.refined import in the client code */ + implicit def refinedInjection[F[_, _]: RefType, T, R: Validate[T, *]]: Injection[F[T, R], T] = + refined.refinedInjection + + implicit def refinedEncoder[F[_, _]: RefType, T: TypedEncoder, R: Validate[T, *]](implicit ct: ClassTag[F[T, R]]): TypedEncoder[F[T, R]] = + refined.refinedEncoder /** Set would be stored as Array */ implicit def setInjection[T]: Injection[Set[T], List[T]] = Injection(_.toList, _.toSet) diff --git a/project/RFDependenciesPlugin.scala b/project/RFDependenciesPlugin.scala index ddedb1d1a..8ac74a84f 100644 --- a/project/RFDependenciesPlugin.scala +++ b/project/RFDependenciesPlugin.scala @@ -54,8 +54,9 @@ object RFDependenciesPlugin extends AutoPlugin { val `scala-logging` = "com.typesafe.scala-logging" %% "scala-logging" % "3.8.0" val stac4s = "com.azavea.stac4s" %% "client" % "0.7.2" val sttpCatsCe2 = "com.softwaremill.sttp.client3" %% "async-http-client-backend-cats-ce2" % "3.3.15" - val frameless = "org.typelevel" %% "frameless-dataset" % "0.10.1" - val `better-files` = "com.github.pathikrit" %% "better-files" % "3.9.1" + val frameless = "org.typelevel" %% "frameless-dataset-spark31" % "0.11.1" + val framelessRefined = "org.typelevel" %% "frameless-refined-spark31" % "0.11.1" + val `better-files` = "com.github.pathikrit" %% "better-files" % "3.9.1" % Test } import autoImport._