-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make BQ annotations serializable #1773
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1773 +/- ##
=========================================
- Coverage 71.67% 69.17% -2.5%
=========================================
Files 176 176
Lines 5402 5402
Branches 410 388 -22
=========================================
- Hits 3872 3737 -135
- Misses 1530 1665 +135
Continue to review full report at Codecov.
|
Hi @anish749. Can you add a test to ensure that the 2 annotations do indeed serialize ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.. I will add them.. Thanks for pointing out. |
// TODO: mock BigQueryClient for fromTable and fromQuery | ||
class TypeProviderTest extends FlatSpec with Matchers { | ||
|
||
val NOW = Instant.now() | ||
|
||
@BigQueryType.fromSchema( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved these classes to the companion object because these annotated classes should be in a companion object (?)
|
||
case class User(@description("user name") name: String, @description("user age") age: Int) | ||
case class Account(@description("account user") user: User, | ||
@description("in USD") balance: Double) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved these to the companion object because the class SchemaProviderTest extends FlatSpec with Matchers
wont be serializable because org.scalatest.FlatSpec
isn't serializable. Not sure if this is the right way to do this. What are your thoughts.
I was getting the following exception if I had in in the class and not in the companion object:
[info] Cause: java.io.NotSerializableException: org.scalatest.Assertions$AssertionsHelper
[info] - field (class "org.scalatest.FlatSpec", name: "assertionsHelper", type: "class org.scalatest.Assertions$AssertionsHelper")
[info] - object (class "com.spotify.scio.bigquery.types.TypeProviderTest", TypeProviderTest)
[info] - field (class "com.spotify.scio.bigquery.types.TypeProviderTest$S1", name: "$outer", type: "class com.spotify.scio.bigquery.types.TypeProviderTest")
[info] - root object (class "com.spotify.scio.bigquery.types.TypeProviderTest$S1", S1(1))
[info] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1182)
I enabled -Dsun.io.serialization.extendedDebugInfo=true
to trace this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
case class User(@description("user name") name: String, @description("user age") age: Int) | ||
case class Account(@description("account user") user: User, | ||
@description("in USD") balance: Double) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I was trying to write Scollections to BQ, and for some generic derivations where a nested type contained a class with a big query annotation, I was finding that the annotations are not serializable. I was thinking of making them seralizable because I think that is an easy fix and hopefully wont break anything.
My use case is something like this:
now my SCollection is of type
[(String, Iterable[CaseClassWithBQAnnotation])]