Giter Club home page Giter Club logo

Comments (8)

nevillelyh avatar nevillelyh commented on June 4, 2024

BaseBigQueryMappableType extends MappableType which should be Serializable, as we as the other traits here:
https://github.com/nevillelyh/shapeless-datatype/blob/master/core/src/main/scala/shapeless/datatype/mappable/MappableType.scala

We should add a few tests too.

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

We can test serialization for *Type instances with the following snippet.

def ensureSerializable[A](a: A): Unit = {
    val baos = new ByteArrayOutputStream()
    val oos = new ObjectOutputStream(baos)
    oos.writeObject(a)
    oos.close()
    baos.close()
  }

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

Hmm... Looks like we already have a SerializableUtils#ensureSerializable method which is used in most tests. Somehow we missed this. Should just add a test case and fix impl.

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

I'm able to reproduce it with the following snippet:

package shapeless.datatype.bigquery

import shapeless.datatype.test.SerializableUtils

object Test {

  object Color extends Enumeration {
    type Color = Value
    val Red, Green, Blue = Value
  }
  case class Record(i: Int, s: String, c: Color.Value)

  def main(args: Array[String]): Unit = {
    val r = Record(10, "hello", Color.Red)

    implicit val colorType = BigQueryType.at[Color.Value]("STRING")(_ => Color.Red, _.toString)
    val bqt = BigQueryType[Record]

    SerializableUtils.ensureSerializable(bqt)
    val fn = (r: Record) => bqt.toTableRow(r)
    SerializableUtils.ensureSerializable(fn.asInstanceOf[Serializable])
    println(bqt.toTableRow(r))
  }
}

BigQueryType itself is serializeable, but the lambda isn't since it pulls in an implicit colorType

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

Pushed a WIP branch. It's still failing for some edge cases.
https://github.com/nevillelyh/shapeless-datatype/tree/neville/serde-dbg

[info] ! BigQueryType.seqs: Exception raised on property evaluation.
[info] > ARG_0: Seqs([I@1311b9c2,List(),Vector())
[info] > Exception: java.io.NotSerializableException: scala.Array$$anon$2
[info] ! BigQueryType.repeated: Exception raised on property evaluation.
[info] > ARG_0: Repeated(List(),List(),List(),List(),List(),List(),List(),List(),List())
[info] > Exception: java.io.NotSerializableException: scala.collection.generic.GenTraversableFactory$$anon$1
[info] + BigQueryType.date time types: OK, passed 100 tests.
[info] + BigQueryType.required: OK, passed 100 tests.
[info] + BigQueryType.mixed: OK, passed 100 tests.
[info] + BigQueryType.custom: OK, passed 100 tests.
[info] + BigQueryType.optional: OK, passed 100 tests.
[info] + BigQueryType.nested: OK, passed 100 tests.

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

The seqs & repeated failures are caused by CanBuildFrom not serializable. I made a workaround and now it's hitting some implicit lookup issue.

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

So fixed almost everything except for Array[T], since Array.newBuilder requires an (implicit t: ClassTag[T]) argument which isn't available.

from shapeless-datatype.

nevillelyh avatar nevillelyh commented on June 4, 2024

Fixed in 1445a26 and 39b317b

from shapeless-datatype.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.