@@ -30,15 +30,9 @@ import org.apache.beam.sdk.io.Compression
30
30
import org .apache .beam .sdk .io .gcp .bigquery .BigQueryIO .TypedRead .Method
31
31
import org .apache .beam .sdk .io .fs .EmptyMatchTreatment
32
32
import org .apache .beam .sdk .transforms .errorhandling .{BadRecord , ErrorHandler }
33
- import org .slf4j .{Logger , LoggerFactory }
34
-
35
- object ScioContextOps {
36
- @ transient private lazy val logger : Logger = LoggerFactory .getLogger(this .getClass)
37
- }
38
33
39
34
/** Enhanced version of [[ScioContext ]] with BigQuery methods. */
40
35
final class ScioContextOps (private val self : ScioContext ) extends AnyVal {
41
- import ScioContextOps ._
42
36
43
37
/**
44
38
* Get an SCollection for a BigQuery SELECT query. Both
@@ -85,13 +79,10 @@ final class ScioContextOps(private val self: ScioContext) extends AnyVal {
85
79
configOverride : BigQueryIO .ReadParam .ConfigOverride [TableRow ] =
86
80
BigQueryIO .ReadParam .DefaultConfigOverride
87
81
): SCollection [TableRow ] = {
88
- if (table.filter.nonEmpty) {
89
- logger.warn(
90
- " Using filtered table with standard API. " +
91
- " selectedFields and rowRestriction are ignored. " +
92
- " Use bigQueryStorage instead"
93
- )
94
- }
82
+ require(
83
+ table.filter.isEmpty,
84
+ " Cannot use filtered table with standard API. Use bigQueryStorage instead"
85
+ )
95
86
val params = BigQueryIO .TableReadParam (
96
87
BigQueryIO .Format .Default (),
97
88
Method .DEFAULT ,
@@ -107,13 +98,10 @@ final class ScioContextOps(private val self: ScioContext) extends AnyVal {
107
98
configOverride : BigQueryIO .ReadParam .ConfigOverride [T ] =
108
99
BigQueryIO .ReadParam .DefaultConfigOverride
109
100
): SCollection [T ] = {
110
- if (table.filter.nonEmpty) {
111
- logger.warn(
112
- " Using filtered table with standard API. " +
113
- " selectedFields and rowRestriction are ignored. " +
114
- " Use bigQueryStorage instead"
115
- )
116
- }
101
+ require(
102
+ table.filter.isEmpty,
103
+ " Cannot use filtered table with standard API. Use bigQueryStorageFormat instead"
104
+ )
117
105
val params = BigQueryIO .TableReadParam (
118
106
format,
119
107
Method .DEFAULT ,
@@ -123,23 +111,6 @@ final class ScioContextOps(private val self: ScioContext) extends AnyVal {
123
111
self.read(BigQueryIO [T ](table))(params)
124
112
}
125
113
126
- /**
127
- * Get an SCollection for a BigQuery table using the storage API.
128
- *
129
- * @param selectedFields
130
- * names of the fields in the table that should be read. If empty, all fields will be read. If
131
- * the specified field is a nested field, all the sub-fields in the field will be selected.
132
- * Fields will always appear in the generated class in the same order as they appear in the
133
- * table, regardless of the order specified in selectedFields.
134
- * @param rowRestriction
135
- * SQL text filtering statement, similar ti a WHERE clause in a query. Currently, we support
136
- * combinations of predicates that are a comparison between a column and a constant value in SQL
137
- * statement. Aggregates are not supported. For example:
138
- *
139
- * {{{
140
- * "a > DATE '2014-09-27' AND (b > 5 AND c LIKE 'date')"
141
- * }}}
142
- */
143
114
def bigQueryStorage (
144
115
table : Table ,
145
116
errorHandler : ErrorHandler [BadRecord , _] = BigQueryIO .ReadParam .DefaultErrorHandler ,
@@ -234,13 +205,10 @@ final class ScioContextOps(private val self: ScioContext) extends AnyVal {
234
205
configOverride
235
206
)
236
207
case t : Table =>
237
- if (t.filter.nonEmpty) {
238
- logger.warn(
239
- " Using filtered table with standard API. " +
240
- " selectedFields and rowRestriction are ignored. " +
241
- " Use typedBigQueryStorage instead"
242
- )
243
- }
208
+ require(
209
+ t.filter.isEmpty,
210
+ " Cannot use filtered table with standard API. Use typedBigQuery instead"
211
+ )
244
212
BigQueryIO .TableReadParam [T ](
245
213
format,
246
214
Method .DEFAULT ,
0 commit comments