Skip to content

Commit 06d4dd3

Browse files
authored
Merge pull request #1610 from data-integrations/table-definition-fix
[PLUGIN-1948] Handle unsupported BigQuery table types gracefully in PartitionedBigQueryInputFormat
2 parents 8d18d63 + 6073d65 commit 06d4dd3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/main/java/io/cdap/plugin/gcp/bigquery/source/PartitionedBigQueryInputFormat.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void processQuery(JobContext context) throws IOException, InterruptedExc
157157
query = generateQuery(partitionFromDate, partitionToDate, filter, datasetProjectId,
158158
datasetId,
159159
tableName, limit, orderBy,
160-
isPartitionFilterRequired, (StandardTableDefinition) tableDefinition);
160+
isPartitionFilterRequired, tableDefinition);
161161
}
162162

163163
if (query != null) {
@@ -181,14 +181,21 @@ private void processQuery(JobContext context) throws IOException, InterruptedExc
181181
@VisibleForTesting
182182
String generateQuery(String partitionFromDate, String partitionToDate, String filter,
183183
String datasetProject, String dataset, String table, String limit, String orderBy,
184-
Boolean isPartitionFilterRequired, StandardTableDefinition tableDefinition) {
184+
Boolean isPartitionFilterRequired, TableDefinition tableDef) {
185185

186186
if (Strings.isNullOrEmpty(filter) && Strings.isNullOrEmpty(orderBy) && Strings.isNullOrEmpty(
187187
limit)
188188
&& Strings.isNullOrEmpty(partitionFromDate) && Strings.isNullOrEmpty(partitionToDate)) {
189189
return null;
190190
}
191191

192+
if (!(tableDef instanceof StandardTableDefinition)) {
193+
throw new IllegalArgumentException(
194+
String.format("Unsupported BigQuery table type for filtering/partitioning: %s. " +
195+
"Cannot apply filters, limits, or ordering.", tableDef.getType()));
196+
}
197+
198+
StandardTableDefinition tableDefinition = (StandardTableDefinition) tableDef;
192199
RangePartitioning rangePartitioning = tableDefinition.getRangePartitioning();
193200
TimePartitioning timePartitioning = tableDefinition.getTimePartitioning();
194201
StringBuilder condition = new StringBuilder();

0 commit comments

Comments
 (0)