1919import static com .google .common .base .Preconditions .checkNotNull ;
2020
2121import com .google .cloud .Page ;
22+ import com .google .cloud .bigquery .BigQuery .DatasetDeleteOption ;
2223import com .google .cloud .bigquery .BigQuery .DatasetOption ;
2324import com .google .cloud .bigquery .BigQuery .TableListOption ;
2425import com .google .cloud .bigquery .BigQuery .TableOption ;
@@ -144,6 +145,16 @@ public Dataset build() {
144145 /**
145146 * Checks if this dataset exists.
146147 *
148+ * <p>Example of checking whether a dataset exists.
149+ * <pre> {@code
150+ * boolean exists = dataset.exists();
151+ * if (exists) {
152+ * // the dataset exists
153+ * } else {
154+ * // the dataset was not found
155+ * }
156+ * }</pre>
157+ *
147158 * @return {@code true} if this dataset exists, {@code false} otherwise
148159 * @throws BigQueryException upon failure
149160 */
@@ -155,6 +166,14 @@ public boolean exists() {
155166 * Fetches current dataset's latest information. Returns {@code null} if the dataset does not
156167 * exist.
157168 *
169+ * <p>Example of reloading a dataset.
170+ * <pre> {@code
171+ * Dataset latestDataset = dataset.reload();
172+ * if (latestDataset == null) {
173+ * // The dataset was not found
174+ * }
175+ * }</pre>
176+ *
158177 * @param options dataset options
159178 * @return a {@code Dataset} object with latest information or {@code null} if not found
160179 * @throws BigQueryException upon failure
@@ -167,6 +186,14 @@ public Dataset reload(DatasetOption... options) {
167186 * Updates the dataset's information with this dataset's information. Dataset's user-defined id
168187 * cannot be changed. A new {@code Dataset} object is returned.
169188 *
189+ * <p>Example of updating a dataset.
190+ * <pre> {@code
191+ * String friendlyName = "my_friendly_name";
192+ * Builder builder = dataset.toBuilder();
193+ * builder.friendlyName(friendlyName);
194+ * Dataset updatedDataset = builder.build().update();
195+ * }</pre>
196+ *
170197 * @param options dataset options
171198 * @return a {@code Dataset} object with updated information
172199 * @throws BigQueryException upon failure
@@ -178,16 +205,36 @@ public Dataset update(DatasetOption... options) {
178205 /**
179206 * Deletes this dataset.
180207 *
208+ * <p>Example of deleting a dataset.
209+ * <pre> {@code
210+ * boolean deleted = dataset.delete();
211+ * if (deleted) {
212+ * // The dataset was deleted
213+ * } else {
214+ * // The dataset was not found
215+ * }
216+ * }</pre>
217+ *
181218 * @return {@code true} if dataset was deleted, {@code false} if it was not found
182219 * @throws BigQueryException upon failure
183220 */
184- public boolean delete () {
185- return bigquery .delete (datasetId ());
221+ public boolean delete (DatasetDeleteOption ... options ) {
222+ return bigquery .delete (datasetId (), options );
186223 }
187224
188225 /**
189226 * Returns the paginated list of tables in this dataset.
190227 *
228+ * <p>Example of listing tables in the dataset.
229+ * <pre> {@code
230+ * Page<Table> tables = dataset.list();
231+ * Iterator<Table> tableIterator = tables.iterateAll();
232+ * while (tableIterator.hasNext()) {
233+ * Table table = tableIterator.next();
234+ * // do something with the table
235+ * }
236+ * }</pre>
237+ *
191238 * @param options options for listing tables
192239 * @throws BigQueryException upon failure
193240 */
@@ -198,6 +245,12 @@ public Page<Table> list(TableListOption... options) {
198245 /**
199246 * Returns the requested table in this dataset or {@code null} if not found.
200247 *
248+ * <p>Example of getting a table in the dataset.
249+ * <pre> {@code
250+ * String tableName = “my_table”;
251+ * Table table = dataset.get(tableName);
252+ * }</pre>
253+ *
201254 * @param table user-defined id of the requested table
202255 * @param options table options
203256 * @throws BigQueryException upon failure
@@ -209,6 +262,18 @@ public Table get(String table, TableOption... options) {
209262 /**
210263 * Creates a new table in this dataset.
211264 *
265+ * <p>Example of creating a table in the dataset with schema and time partitioning.
266+ * <pre> {@code
267+ * String tableName = “my_table”;
268+ * String fieldName = “my_field”;
269+ * Schema schema = Schema.of(Field.of(fieldName, Type.string()));
270+ * StandardTableDefinition definition = StandardTableDefinition.builder()
271+ * .schema(schema)
272+ * .timePartitioning(TimePartitioning.of(TimePartitioning.Type.DAY))
273+ * .build();
274+ * Table table = dataset.create(tableName, definition);
275+ * }</pre>
276+ *
212277 * @param table the table's user-defined id
213278 * @param definition the table's definition
214279 * @param options options for table creation
0 commit comments