Skip to content
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
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions project/RFDependenciesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally with a full refined types support!

val `better-files` = "com.github.pathikrit" %% "better-files" % "3.9.1" % Test
}
import autoImport._

Expand Down