@@ -67,6 +67,7 @@ public final class QueryJobConfiguration extends JobConfiguration {
67
67
private final Clustering clustering ;
68
68
private final Long jobTimeoutMs ;
69
69
private final Map <String , String > labels ;
70
+ private final RangePartitioning rangePartitioning ;
70
71
71
72
/**
72
73
* Priority levels for a query. If not specified the priority is assumed to be {@link
@@ -114,6 +115,7 @@ public static final class Builder
114
115
private Clustering clustering ;
115
116
private Long jobTimeoutMs ;
116
117
private Map <String , String > labels ;
118
+ private RangePartitioning rangePartitioning ;
117
119
118
120
private Builder () {
119
121
super (Type .QUERY );
@@ -144,6 +146,7 @@ private Builder(QueryJobConfiguration jobConfiguration) {
144
146
this .clustering = jobConfiguration .clustering ;
145
147
this .jobTimeoutMs = jobConfiguration .jobTimeoutMs ;
146
148
this .labels = jobConfiguration .labels ;
149
+ this .rangePartitioning = jobConfiguration .rangePartitioning ;
147
150
}
148
151
149
152
private Builder (com .google .api .services .bigquery .model .JobConfiguration configurationPb ) {
@@ -233,6 +236,10 @@ private Builder(com.google.api.services.bigquery.model.JobConfiguration configur
233
236
if (configurationPb .getLabels () != null ) {
234
237
this .labels = configurationPb .getLabels ();
235
238
}
239
+ if (queryConfigurationPb .getRangePartitioning () != null ) {
240
+ this .rangePartitioning =
241
+ RangePartitioning .fromPb (queryConfigurationPb .getRangePartitioning ());
242
+ }
236
243
}
237
244
238
245
/** Sets the BigQuery SQL query to execute. */
@@ -561,6 +568,17 @@ public Builder setLabels(Map<String, String> labels) {
561
568
return this ;
562
569
}
563
570
571
+ /**
572
+ * Range partitioning specification for this table. Only one of timePartitioning and
573
+ * rangePartitioning should be specified.
574
+ *
575
+ * @param rangePartitioning rangePartitioning or {@code null} for none
576
+ */
577
+ public Builder setRangePartitioning (RangePartitioning rangePartitioning ) {
578
+ this .rangePartitioning = rangePartitioning ;
579
+ return this ;
580
+ }
581
+
564
582
public QueryJobConfiguration build () {
565
583
return new QueryJobConfiguration (this );
566
584
}
@@ -600,6 +618,7 @@ private QueryJobConfiguration(Builder builder) {
600
618
this .clustering = builder .clustering ;
601
619
this .jobTimeoutMs = builder .jobTimeoutMs ;
602
620
this .labels = builder .labels ;
621
+ this .rangePartitioning = builder .rangePartitioning ;
603
622
}
604
623
605
624
/**
@@ -779,6 +798,11 @@ public Map<String, String> getLabels() {
779
798
return labels ;
780
799
}
781
800
801
+ /** Returns the range partitioning specification for the table */
802
+ public RangePartitioning getRangePartitioning () {
803
+ return rangePartitioning ;
804
+ }
805
+
782
806
@ Override
783
807
public Builder toBuilder () {
784
808
return new Builder (this );
@@ -809,7 +833,8 @@ ToStringHelper toStringHelper() {
809
833
.add ("timePartitioning" , timePartitioning )
810
834
.add ("clustering" , clustering )
811
835
.add ("jobTimeoutMs" , jobTimeoutMs )
812
- .add ("labels" , labels );
836
+ .add ("labels" , labels )
837
+ .add ("rangePartitioning" , rangePartitioning );
813
838
}
814
839
815
840
@ Override
@@ -843,7 +868,8 @@ public int hashCode() {
843
868
timePartitioning ,
844
869
clustering ,
845
870
jobTimeoutMs ,
846
- labels );
871
+ labels ,
872
+ rangePartitioning );
847
873
}
848
874
849
875
@ Override
@@ -939,6 +965,9 @@ com.google.api.services.bigquery.model.JobConfiguration toPb() {
939
965
if (labels != null ) {
940
966
configurationPb .setLabels (labels );
941
967
}
968
+ if (rangePartitioning != null ) {
969
+ queryConfigurationPb .setRangePartitioning (rangePartitioning .toPb ());
970
+ }
942
971
configurationPb .setQuery (queryConfigurationPb );
943
972
return configurationPb ;
944
973
}
0 commit comments