Skip to content

Commit a8c5b67

Browse files
Make schema val @transient in ParquetType (#619)
* Make schema val @transient in ParquetType * fix test * Fixing the Avro compat error in serialization test (#620) Co-authored-by: Claire McGinty <[email protected]> Co-authored-by: Andrew Kabas <[email protected]>
1 parent ad42b3f commit a8c5b67

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

parquet/src/main/scala/magnolify/parquet/ParquetType.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ object ParquetType {
8686
)(implicit f: ParquetField[T], pa: ParquetArray): ParquetType[T] = f match {
8787
case r: ParquetField.Record[_] =>
8888
new ParquetType[T] {
89-
override lazy val schema: MessageType = Schema.message(r.schema(cm))
90-
override lazy val avroSchema: AvroSchema = {
89+
@transient override lazy val schema: MessageType = Schema.message(r.schema(cm))
90+
@transient override lazy val avroSchema: AvroSchema = {
9191
val s = new AvroSchemaConverter().convert(schema)
9292
// add doc to avro schema
9393
SchemaUtil.deepCopy(s, f.typeDoc, f.fieldDocs.get)

parquet/src/test/scala/magnolify/parquet/AvroParquetSuite.scala

+6-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ class AvroParquetSuite extends MagnolifySuite {
4949
schemaErrors: List[String] = List.empty
5050
)(implicit
5151
at: AvroType[T],
52-
pt: ParquetType[T],
52+
tpe: ParquetType[T],
5353
eq: Eq[T]
5454
): Unit = {
55+
// Ensure serializable even after evaluation of `schema` and `avroSchema`
56+
val parquetSchema = tpe.schema
57+
val avroSchema = tpe.avroSchema
58+
val pt = ensureSerializable(tpe)
59+
5560
val name = className[T]
5661

5762
property(s"$name.avro2parquet") {

parquet/src/test/scala/magnolify/parquet/ParquetTypeSuite.scala

+3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class ParquetTypeSuite extends MagnolifySuite {
4444
t: ParquetType[T],
4545
eq: Eq[T]
4646
): Unit = {
47+
// Ensure serializable even after evaluation of `schema`
48+
val parquetSchema = t.schema
4749
val tpe = ensureSerializable(t)
50+
4851
property(className[T]) {
4952
Prop.forAll { t: T =>
5053
val out = new TestOutputFile

0 commit comments

Comments
 (0)