@@ -57,6 +57,25 @@ public abstract static class Builder
57
57
@ Override
58
58
public abstract Builder setType (Type type );
59
59
60
+ /**
61
+ * Sets the time partitioning configuration for the materialized view. If not set, the
62
+ * materialized view is not time-partitioned.
63
+ */
64
+ public abstract Builder setTimePartitioning (TimePartitioning timePartitioning );
65
+
66
+ /**
67
+ * Sets the range partitioning configuration for the materialized view. Only one of
68
+ * timePartitioning and rangePartitioning should be specified.
69
+ */
70
+ public abstract Builder setRangePartitioning (RangePartitioning rangePartitioning );
71
+
72
+ /**
73
+ * Set the clustering configuration for the materialized view. If not set, the materialized view
74
+ * is not clustered. BigQuery supports clustering for both partitioned and non-partitioned
75
+ * materialized views.
76
+ */
77
+ public abstract Builder setClustering (Clustering clustering );
78
+
60
79
/** Creates a {@code MaterializedViewDefinition} object. */
61
80
@ Override
62
81
public abstract MaterializedViewDefinition build ();
@@ -86,6 +105,27 @@ public abstract static class Builder
86
105
@ Nullable
87
106
public abstract Long getRefreshIntervalMs ();
88
107
108
+ /**
109
+ * Returns the time partitioning configuration for this table. If {@code null}, the table is not
110
+ * time-partitioned.
111
+ */
112
+ @ Nullable
113
+ public abstract TimePartitioning getTimePartitioning ();
114
+
115
+ /**
116
+ * Returns the range partitioning configuration for this table. If {@code null}, the table is not
117
+ * range-partitioned.
118
+ */
119
+ @ Nullable
120
+ public abstract RangePartitioning getRangePartitioning ();
121
+
122
+ /**
123
+ * Returns the clustering configuration for this table. If {@code null}, the table is not
124
+ * clustered.
125
+ */
126
+ @ Nullable
127
+ public abstract Clustering getClustering ();
128
+
89
129
/** Returns a builder for the {@code MaterializedViewDefinition} object. */
90
130
public abstract Builder toBuilder ();
91
131
@@ -107,6 +147,15 @@ Table toPb() {
107
147
materializedViewDefinition .setRefreshIntervalMs (getRefreshIntervalMs ());
108
148
}
109
149
tablePb .setMaterializedView (materializedViewDefinition );
150
+ if (getTimePartitioning () != null ) {
151
+ tablePb .setTimePartitioning (getTimePartitioning ().toPb ());
152
+ }
153
+ if (getRangePartitioning () != null ) {
154
+ tablePb .setRangePartitioning (getRangePartitioning ().toPb ());
155
+ }
156
+ if (getClustering () != null ) {
157
+ tablePb .setClustering (getClustering ().toPb ());
158
+ }
110
159
return tablePb ;
111
160
}
112
161
@@ -149,6 +198,15 @@ static MaterializedViewDefinition fromPb(Table tablePb) {
149
198
if (materializedViewDefinition .getRefreshIntervalMs () != null ) {
150
199
builder .setRefreshIntervalMs (materializedViewDefinition .getRefreshIntervalMs ());
151
200
}
201
+ if (tablePb .getTimePartitioning () != null ) {
202
+ builder .setTimePartitioning (TimePartitioning .fromPb (tablePb .getTimePartitioning ()));
203
+ }
204
+ if (tablePb .getRangePartitioning () != null ) {
205
+ builder .setRangePartitioning (RangePartitioning .fromPb (tablePb .getRangePartitioning ()));
206
+ }
207
+ if (tablePb .getClustering () != null ) {
208
+ builder .setClustering (Clustering .fromPb (tablePb .getClustering ()));
209
+ }
152
210
}
153
211
return builder .build ();
154
212
}
0 commit comments