mjakubowski84 / parquet4s

Read and write Parquet in Scala. Use Scala classes as schema. No need to start a cluster.
https://mjakubowski84.github.io/parquet4s/
MIT License
283 stars 65 forks source link

Multiple custom TypedSchemaDefs are ambiguous #258

Closed Jasper-M closed 2 years ago

Jasper-M commented 2 years ago

Using version 2.3.0, on Scala 2.12. Also tested on the latest 2.13 version.

import com.github.mjakubowski84.parquet4s.ParquetSchemaResolver.TypedSchemaDef
import java.time.{Instant, LocalDateTime}
import java.util.UUID

object ParquetImplicits {
  implicit def instantSchemaDef(implicit ldtSchemaDef: TypedSchemaDef[LocalDateTime]): TypedSchemaDef[Instant] = 
      ldtSchemaDef.typed[Instant]
  implicit def uuidSchemaDef(implicit strSchemaDef: TypedSchemaDef[String]): TypedSchemaDef[UUID] = 
      strSchemaDef.typed[UUID]
}

import ParquetImplicits._

case class Foo(id: Int, ts: Instant)

implicitly[TypedSchemaDef[Foo]]

This produces the following error

ambiguous implicit values:
 both method instantSchemaDef in object ParquetImplicits of type (implicit ldtSchemaDef: com.github.mjakubowski84.parquet4s.ParquetSchemaResolver.TypedSchemaDef[java.time.LocalDateTime]): com.github.mjakubowski84.parquet4s.ParquetSchemaResolver.TypedSchemaDef[java.time.Instant]
 and method uuidSchemaDef in object ParquetImplicits of type (implicit strSchemaDef: com.github.mjakubowski84.parquet4s.ParquetSchemaResolver.TypedSchemaDef[String]): com.github.mjakubowski84.parquet4s.ParquetSchemaResolver.TypedSchemaDef[java.util.UUID]
 match expected type com.github.mjakubowski84.parquet4s.SchemaDef

In 1.9.x this worked.

mjakubowski84 commented 2 years ago

Thanks for reporting. I am looking into it already. It is going to be fixed in upcoming release this week.

mjakubowski84 commented 2 years ago

@Jasper-M Version 2.4.0 is released - the issue should be fixed.