@@ -57,6 +57,25 @@ public abstract static class Builder
5757 @ Override
5858 public abstract Builder setType (Type type );
5959
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+
6079 /** Creates a {@code MaterializedViewDefinition} object. */
6180 @ Override
6281 public abstract MaterializedViewDefinition build ();
@@ -86,6 +105,27 @@ public abstract static class Builder
86105 @ Nullable
87106 public abstract Long getRefreshIntervalMs ();
88107
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+
89129 /** Returns a builder for the {@code MaterializedViewDefinition} object. */
90130 public abstract Builder toBuilder ();
91131
@@ -107,6 +147,15 @@ Table toPb() {
107147 materializedViewDefinition .setRefreshIntervalMs (getRefreshIntervalMs ());
108148 }
109149 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+ }
110159 return tablePb ;
111160 }
112161
@@ -149,6 +198,15 @@ static MaterializedViewDefinition fromPb(Table tablePb) {
149198 if (materializedViewDefinition .getRefreshIntervalMs () != null ) {
150199 builder .setRefreshIntervalMs (materializedViewDefinition .getRefreshIntervalMs ());
151200 }
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+ }
152210 }
153211 return builder .build ();
154212 }
0 commit comments