@@ -39,7 +39,7 @@ object BigQueryTypeInjector {
39
39
s " $BQTNamespace.toTable "
40
40
)
41
41
42
- private val CaseClassSuper =
42
+ private val HasAnnotationSuper =
43
43
" _root_.com.spotify.scio.bigquery.types.BigQueryType.HasAnnotation"
44
44
45
45
private def bqAnnotation (sc : ScClass ): Option [String ] =
@@ -76,14 +76,12 @@ object BigQueryTypeInjector {
76
76
annotation match {
77
77
case a if a.contains(FromQuery ) =>
78
78
val simple = """
79
- |def query: _root_.java.lang.String = ???
80
79
|def queryRaw: _root_.java.lang.String = ???
81
80
|""" .stripMargin
82
81
83
82
bqQuerySignature(c)
84
83
.map { params =>
85
84
simple + s """
86
- |def query( $params): _root_.java.lang.String = ???
87
85
|def queryAsSource( $params): _root_.com.spotify.scio.bigquery.Query = ???
88
86
| """ .stripMargin
89
87
}
@@ -110,25 +108,21 @@ final class BigQueryTypeInjector extends AnnotationTypeInjector {
110
108
override def injectFunctions (source : ScTypeDefinition ): Seq [String ] =
111
109
source match {
112
110
case c : ScClass if bqAnnotation(c).isDefined =>
113
- val result = for {
114
- cc <- Option (c.containingClass)
115
- qn <- Option (cc.getQualifiedName)
111
+ val fields = for {
112
+ cc <- Option (c.containingClass).toSeq
113
+ qn <- Option (cc.getQualifiedName).toSeq
116
114
parent = qn.init
117
- defs <- {
118
- generatedCaseClasses(parent, c)
119
- .find(_.contains(CaseClassSuper ))
120
- .map(getApplyPropsSignature)
121
- .map(v => s " def $v = ??? " )
122
- }
123
- } yield defs
124
-
125
- result.toSeq
126
- case _ => Seq .empty
115
+ cls <- generatedCaseClasses(parent, c).find(_.contains(HasAnnotationSuper )).toSeq
116
+ v <- getApplyPropsSignature(cls)
117
+ } yield s " def $v = ??? "
118
+ CaseClassFunctions ++ fields
119
+ case _ =>
120
+ Seq .empty
127
121
}
128
122
129
123
override def injectSupers (source : ScTypeDefinition ): Seq [String ] =
130
124
source match {
131
- case c : ScClass if bqAnnotation(c).isDefined => Seq (CaseClassSuper )
125
+ case c : ScClass if bqAnnotation(c).isDefined => Seq (CaseClassSuper , HasAnnotationSuper )
132
126
case _ => Seq .empty
133
127
}
134
128
@@ -143,7 +137,7 @@ final class BigQueryTypeInjector extends AnnotationTypeInjector {
143
137
case c : ScClass if bqAnnotation(c).isDefined =>
144
138
val (annotated, other) =
145
139
generatedCaseClasses(source.getQualifiedName.init, c).partition(
146
- _.contains(CaseClassSuper )
140
+ _.contains(HasAnnotationSuper )
147
141
)
148
142
(c, (annotated.headOption, other))
149
143
}
0 commit comments