Comments (8)
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.
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.
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.
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.
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.
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.
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.
from shapeless-datatype.
Related Issues (19)
- Use Iterable instead of Seq for MapRecords
- RecordMappers involving transformations on Maps do not compile HOT 1
- RecordMappers: improvements on Option support
- scalajs/native support for core HOT 1
- Creating a generic AvroType HOT 7
- Avro support Maps HOT 2
- Add TensorFlow Example protobuf support
- Add Avro GenericRecord support
- [datastore]: StackOverflow for Case Class with over 22 fields HOT 9
- Deriving logic prefers derived case class mapper over custom provided
- Update datastore clients HOT 1
- Fail nested type for TensorFlowType at compile time
- Support Sets in FromMappable and ToMappable HOT 17
- Use property BigQuery TableRow type instead of Map[String, Any]
- Add helpers for custom primitive types
- Reduce boilerplate of ScalaCheck forAll usage HOT 1
- Make *Type trait extends implicits again HOT 1
- Try magnolia based derivation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shapeless-datatype.