23
23
public final class HivePartitioningOptions {
24
24
25
25
private final String mode ;
26
+ private final Boolean requirePartitionFilter ;
26
27
private final String sourceUriPrefix ;
27
28
28
29
public static final class Builder {
29
30
30
31
private String mode ;
32
+ private Boolean requirePartitionFilter ;
31
33
private String sourceUriPrefix ;
32
34
33
35
private Builder () {}
34
36
35
37
private Builder (HivePartitioningOptions options ) {
36
38
this .mode = options .mode ;
39
+ this .requirePartitionFilter = options .requirePartitionFilter ;
37
40
this .sourceUriPrefix = options .sourceUriPrefix ;
38
41
}
39
42
@@ -50,6 +53,17 @@ public Builder setMode(String mode) {
50
53
return this ;
51
54
}
52
55
56
+ /**
57
+ * [Optional] If set to true, queries over this table require a partition filter that can be
58
+ * used for partition elimination to be specified. Note that this field should only be true when
59
+ * creating a permanent external table or querying a temporary external table. Hive-partitioned
60
+ * loads with requirePartitionFilter explicitly set to true will fail.
61
+ */
62
+ public Builder setRequirePartitionFilter (Boolean requirePartitionFilter ) {
63
+ this .requirePartitionFilter = requirePartitionFilter ;
64
+ return this ;
65
+ }
66
+
53
67
/**
54
68
* [Optional] When hive partition detection is requested, a common prefix for all source uris
55
69
* should be supplied. The prefix must end immediately before the partition key encoding begins.
@@ -72,6 +86,7 @@ public HivePartitioningOptions build() {
72
86
73
87
private HivePartitioningOptions (Builder builder ) {
74
88
this .mode = builder .mode ;
89
+ this .requirePartitionFilter = builder .requirePartitionFilter ;
75
90
this .sourceUriPrefix = builder .sourceUriPrefix ;
76
91
}
77
92
@@ -80,6 +95,14 @@ public String getMode() {
80
95
return mode ;
81
96
}
82
97
98
+ /**
99
+ * Returns true if a partition filter (that can be used for partition elimination) is required for
100
+ * queries over this table.
101
+ */
102
+ public Boolean getRequirePartitionFilter () {
103
+ return requirePartitionFilter ;
104
+ }
105
+
83
106
/* Returns the sourceUriPrefix of hive partitioning */
84
107
public String getSourceUriPrefix () {
85
108
return sourceUriPrefix ;
@@ -99,6 +122,7 @@ public static Builder newBuilder() {
99
122
public String toString () {
100
123
return MoreObjects .toStringHelper (this )
101
124
.add ("mode" , mode )
125
+ .add ("requirePartitionFilter" , requirePartitionFilter )
102
126
.add ("sourceUriPrefix" , sourceUriPrefix )
103
127
.toString ();
104
128
}
@@ -109,6 +133,8 @@ public boolean equals(Object obj) {
109
133
|| obj != null
110
134
&& obj .getClass ().equals (HivePartitioningOptions .class )
111
135
&& Objects .equals (mode , ((HivePartitioningOptions ) obj ).getMode ())
136
+ && Objects .equals (
137
+ requirePartitionFilter , ((HivePartitioningOptions ) obj ).getRequirePartitionFilter ())
112
138
&& Objects .equals (
113
139
sourceUriPrefix , ((HivePartitioningOptions ) obj ).getSourceUriPrefix ());
114
140
}
@@ -122,6 +148,7 @@ com.google.api.services.bigquery.model.HivePartitioningOptions toPb() {
122
148
com .google .api .services .bigquery .model .HivePartitioningOptions options =
123
149
new com .google .api .services .bigquery .model .HivePartitioningOptions ();
124
150
options .setMode (mode );
151
+ options .setRequirePartitionFilter (requirePartitionFilter );
125
152
options .setSourceUriPrefix (sourceUriPrefix );
126
153
return options ;
127
154
}
@@ -132,6 +159,9 @@ static HivePartitioningOptions fromPb(
132
159
if (options .getMode () != null ) {
133
160
builder .setMode (options .getMode ());
134
161
}
162
+ if (options .getRequirePartitionFilter () != null ) {
163
+ builder .setRequirePartitionFilter (options .getRequirePartitionFilter ());
164
+ }
135
165
if (options .getSourceUriPrefix () != null ) {
136
166
builder .setSourceUriPrefix (options .getSourceUriPrefix ());
137
167
}
0 commit comments