Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>io.cdap.plugin</groupId>
<artifactId>google-cloud</artifactId>
<version>0.23.6</version>
<version>0.23.7-SNAPSHOT</version>
<name>Google Cloud Plugins</name>
<packaging>jar</packaging>
<description>Plugins for Google Big Query</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.api.services.bigquery.model.TableReference;
import com.google.cloud.bigquery.RangePartitioning;
import com.google.cloud.bigquery.StandardTableDefinition;
import com.google.cloud.bigquery.TableDefinition;
import com.google.cloud.bigquery.TableDefinition.Type;
import com.google.cloud.bigquery.TimePartitioning;
import com.google.cloud.hadoop.io.bigquery.AbstractBigQueryInputFormat;
Expand Down Expand Up @@ -139,7 +140,7 @@ private void processQuery(JobContext context) throws IOException, InterruptedExc
datasetProjectId, datasetId, tableName, serviceAccount, isServiceAccountFilePath, null);
Type type = Objects.requireNonNull(bigQueryTable).getDefinition().getType();
Boolean isPartitionFilterRequired = bigQueryTable.getRequirePartitionFilter();
StandardTableDefinition tableDefinition = Objects.requireNonNull(bigQueryTable).getDefinition();
TableDefinition tableDefinition = Objects.requireNonNull(bigQueryTable).getDefinition();

String query;
if (type == Type.VIEW || type == Type.MATERIALIZED_VIEW || type == Type.EXTERNAL) {
Expand Down Expand Up @@ -173,14 +174,21 @@ private void processQuery(JobContext context) throws IOException, InterruptedExc
@VisibleForTesting
String generateQuery(String partitionFromDate, String partitionToDate, String filter,
String datasetProject, String dataset, String table, String limit, String orderBy,
Boolean isPartitionFilterRequired, StandardTableDefinition tableDefinition) {
Boolean isPartitionFilterRequired, TableDefinition tableDef) {

if (Strings.isNullOrEmpty(filter) && Strings.isNullOrEmpty(orderBy) && Strings.isNullOrEmpty(
limit)
&& Strings.isNullOrEmpty(partitionFromDate) && Strings.isNullOrEmpty(partitionToDate)) {
return null;
}

if (!(tableDef instanceof StandardTableDefinition)) {
throw new IllegalArgumentException(
String.format("Unsupported BigQuery table type for filtering/partitioning: %s. " +
"Cannot apply filters, limits, or ordering.", tableDef.getType()));
}

StandardTableDefinition tableDefinition = (StandardTableDefinition) tableDef;
RangePartitioning rangePartitioning = tableDefinition.getRangePartitioning();
TimePartitioning timePartitioning = tableDefinition.getTimePartitioning();
StringBuilder condition = new StringBuilder();
Expand Down
Loading