Skip to content

Commit

Permalink
BigQuery: Fix Maximum Bytes Billed property. (#4262)
Browse files Browse the repository at this point in the history
* Fix Maximum Bytes Billed

* remove whitespace
  • Loading branch information
Praful Makani authored and chingor13 committed Jan 2, 2019
1 parent 6e2c2dd commit 70d7efb
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SchemaUpdateOption> schemaUpdateOptions;
private final EncryptionConfiguration destinationEncryptionConfiguration;
private final TimePartitioning timePartitioning;
Expand Down Expand Up @@ -104,6 +105,7 @@ public static final class Builder
private Boolean dryRun;
private Boolean useLegacySql = false;
private Integer maximumBillingTier;
private Long maximumBytesBilled;
private List<SchemaUpdateOption> schemaUpdateOptions;
private EncryptionConfiguration destinationEncryptionConfiguration;
private TimePartitioning timePartitioning;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -482,6 +488,18 @@ public Builder setMaximumBillingTier(Integer 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
Expand Down Expand Up @@ -538,6 +556,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;
Expand Down Expand Up @@ -685,6 +704,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
Expand Down Expand Up @@ -731,6 +755,7 @@ ToStringHelper toStringHelper() {
.add("dryRun", dryRun)
.add("useLegacySql", useLegacySql)
.add("maximumBillingTier", maximumBillingTier)
.add("maximumBytesBilled", maximumBytesBilled)
.add("schemaUpdateOptions", schemaUpdateOptions)
.add("timePartitioning", timePartitioning)
.add("clustering", clustering);
Expand Down Expand Up @@ -762,6 +787,7 @@ public int hashCode() {
dryRun,
useLegacySql,
maximumBillingTier,
maximumBytesBilled,
schemaUpdateOptions,
timePartitioning,
clustering);
Expand Down Expand Up @@ -835,6 +861,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<String> schemaUpdateOptionsBuilder = new ImmutableList.Builder<>();
for (JobInfo.SchemaUpdateOption schemaUpdateOption : schemaUpdateOptions) {
Expand Down

0 comments on commit 70d7efb

Please sign in to comment.