From bfa7b64e9565552ff490ca22f5a848e4e42447d4 Mon Sep 17 00:00:00 2001 From: Praful Makani Date: Thu, 27 Dec 2018 18:06:24 +0530 Subject: [PATCH 1/2] Fix Maximum Bytes Billed --- .../cloud/bigquery/QueryJobConfiguration.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java b/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java index a5e741d7f8f3..432826eaf34d 100644 --- a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java +++ b/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java @@ -60,6 +60,7 @@ public final class QueryJobConfiguration extends JobConfiguration { private final Boolean dryRun; private final Boolean useLegacySql; private final Integer maximumBillingTier; + private final Long maximumBytesBilled; private final List schemaUpdateOptions; private final EncryptionConfiguration destinationEncryptionConfiguration; private final TimePartitioning timePartitioning; @@ -104,6 +105,7 @@ public static final class Builder private Boolean dryRun; private Boolean useLegacySql = false; private Integer maximumBillingTier; + private Long maximumBytesBilled; private List schemaUpdateOptions; private EncryptionConfiguration destinationEncryptionConfiguration; private TimePartitioning timePartitioning; @@ -131,6 +133,7 @@ private Builder(QueryJobConfiguration jobConfiguration) { this.dryRun = jobConfiguration.dryRun; this.useLegacySql = jobConfiguration.useLegacySql; this.maximumBillingTier = jobConfiguration.maximumBillingTier; + this.maximumBytesBilled = jobConfiguration.maximumBytesBilled; this.schemaUpdateOptions = jobConfiguration.schemaUpdateOptions; this.destinationEncryptionConfiguration = jobConfiguration.destinationEncryptionConfiguration; this.timePartitioning = jobConfiguration.timePartitioning; @@ -167,6 +170,9 @@ private Builder(com.google.api.services.bigquery.model.JobConfiguration configur if (queryConfigurationPb.getMaximumBillingTier() != null) { maximumBillingTier = queryConfigurationPb.getMaximumBillingTier(); } + if (queryConfigurationPb.getMaximumBytesBilled() != null) { + maximumBytesBilled = queryConfigurationPb.getMaximumBytesBilled(); + } dryRun = configurationPb.getDryRun(); if (queryConfigurationPb.getDestinationTable() != null) { destinationTable = TableId.fromPb(queryConfigurationPb.getDestinationTable()); @@ -481,7 +487,18 @@ public Builder setMaximumBillingTier(Integer maximumBillingTier) { this.maximumBillingTier = maximumBillingTier; return this; } - + + /** + * Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit + * will fail (without incurring a charge). If unspecified, this will be set to your project default. + * + * @param maximumBytesBilled maximum bytes billed for this job + */ + public Builder setMaximumBytesBilled(Long maximumBytesBilled) { + this.maximumBytesBilled = maximumBytesBilled; + return this; + } + /** * [Experimental] Sets options allowing the schema of the destination table to be updated as a * side effect of the query job. Schema update options are supported in two cases: when @@ -538,6 +555,7 @@ private QueryJobConfiguration(Builder builder) { this.dryRun = builder.dryRun; this.useLegacySql = builder.useLegacySql; this.maximumBillingTier = builder.maximumBillingTier; + this.maximumBytesBilled = builder.maximumBytesBilled; this.schemaUpdateOptions = builder.schemaUpdateOptions; this.destinationEncryptionConfiguration = builder.destinationEncryptionConfiguration; this.timePartitioning = builder.timePartitioning; @@ -685,6 +703,11 @@ public Integer getMaximumBillingTier() { return maximumBillingTier; } + /** Returns the optional bytes billed limit for this job. */ + public Long getMaximumBytesBilled() { + return maximumBytesBilled; + } + /** * [Experimental] Returns options allowing the schema of the destination table to be updated as a * side effect of the query job. Schema update options are supported in two cases: when @@ -731,6 +754,7 @@ ToStringHelper toStringHelper() { .add("dryRun", dryRun) .add("useLegacySql", useLegacySql) .add("maximumBillingTier", maximumBillingTier) + .add("maximumBytesBilled", maximumBytesBilled) .add("schemaUpdateOptions", schemaUpdateOptions) .add("timePartitioning", timePartitioning) .add("clustering", clustering); @@ -762,6 +786,7 @@ public int hashCode() { dryRun, useLegacySql, maximumBillingTier, + maximumBytesBilled, schemaUpdateOptions, timePartitioning, clustering); @@ -835,6 +860,9 @@ com.google.api.services.bigquery.model.JobConfiguration toPb() { if (maximumBillingTier != null) { queryConfigurationPb.setMaximumBillingTier(maximumBillingTier); } + if (maximumBytesBilled != null) { + queryConfigurationPb.setMaximumBytesBilled(maximumBytesBilled); + } if (schemaUpdateOptions != null) { ImmutableList.Builder schemaUpdateOptionsBuilder = new ImmutableList.Builder<>(); for (JobInfo.SchemaUpdateOption schemaUpdateOption : schemaUpdateOptions) { From b2397de5d8d2c0846abb85d15d834b7619a17128 Mon Sep 17 00:00:00 2001 From: Praful Makani Date: Thu, 27 Dec 2018 18:40:22 +0530 Subject: [PATCH 2/2] remove whitespace --- .../com/google/cloud/bigquery/QueryJobConfiguration.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java b/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java index 432826eaf34d..9bc906a1fa17 100644 --- a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java +++ b/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/QueryJobConfiguration.java @@ -487,10 +487,11 @@ public Builder setMaximumBillingTier(Integer maximumBillingTier) { this.maximumBillingTier = maximumBillingTier; return this; } - + /** * Limits the bytes billed for this job. Queries that will have bytes billed beyond this limit - * will fail (without incurring a charge). If unspecified, this will be set to your project default. + * will fail (without incurring a charge). If unspecified, this will be set to your project + * default. * * @param maximumBytesBilled maximum bytes billed for this job */ @@ -498,7 +499,7 @@ public Builder setMaximumBytesBilled(Long maximumBytesBilled) { this.maximumBytesBilled = maximumBytesBilled; return this; } - + /** * [Experimental] Sets options allowing the schema of the destination table to be updated as a * side effect of the query job. Schema update options are supported in two cases: when