public class Dataset extends DatasetInfoA Google BigQuery Dataset.
Objects of this class are immutable. Operations that modify the dataset like #update
return a new object. To get a Dataset object with the most recent information use #reload. Dataset adds a layer of service-related functionality over DatasetInfo.
Methods
create(String tableId, TableDefinition definition, BigQuery.TableOption[] options)
public Table create(String tableId, TableDefinition definition, BigQuery.TableOption[] options)Creates a new table in this dataset.
Example of creating a table in the dataset with schema and time partitioning.
String tableName = “my_table”;
String fieldName = “my_field”;
Schema schema = Schema.of(Field.of(fieldName, LegacySQLTypeName.STRING));
StandardTableDefinition definition = StandardTableDefinition.newBuilder()
.setSchema(schema)
.setTimePartitioning(TimePartitioning.of(TimePartitioning.Type.DAY))
.build();
Table table = dataset.create(tableName, definition);
| Parameters | |
|---|---|
| Name | Description |
tableId |
Stringthe table's user-defined id |
definition |
TableDefinitionthe table's definition |
options |
TableOption[]options for table creation |
| Returns | |
|---|---|
| Type | Description |
Table |
a |
delete(BigQuery.DatasetDeleteOption[] options)
public boolean delete(BigQuery.DatasetDeleteOption[] options)Deletes this dataset.
Example of deleting a dataset.
boolean deleted = dataset.delete();
if (deleted) {
// The dataset was deleted
} else {
// The dataset was not found
}
| Parameter | |
|---|---|
| Name | Description |
options |
DatasetDeleteOption[] |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
equals(Object obj)
public final boolean equals(Object obj)| Parameter | |
|---|---|
| Name | Description |
obj |
Object |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
exists()
public boolean exists()Checks if this dataset exists.
Example of checking whether a dataset exists.
boolean exists = dataset.exists();
if (exists) {
// the dataset exists
} else {
// the dataset was not found
}
| Returns | |
|---|---|
| Type | Description |
boolean |
|
get(String tableId, BigQuery.TableOption[] options)
public Table get(String tableId, BigQuery.TableOption[] options)Returns the requested table in this dataset or null if not found.
Example of getting a table in the dataset.
String tableName = “my_table”;
Table table = dataset.get(tableName);
| Parameters | |
|---|---|
| Name | Description |
tableId |
Stringuser-defined id of the requested table |
options |
TableOption[]table options |
| Returns | |
|---|---|
| Type | Description |
Table |
|
getBigQuery()
public BigQuery getBigQuery()Returns the dataset's BigQuery object used to issue requests.
| Returns | |
|---|---|
| Type | Description |
BigQuery |
|
hashCode()
public final int hashCode()| Returns | |
|---|---|
| Type | Description |
int |
|
list(BigQuery.TableListOption[] options)
public Page list(BigQuery.TableListOption[] options)
Returns the paginated list of tables in this dataset.
Example of listing tables in the dataset.
Page tables = dataset.list();
for (Table table : tables.iterateAll()) {
// do something with the table
}
Parameter
Name
Description
options
TableListOption[]
options for listing tables
Returns
Type
Description
Page<Table>
reload(BigQuery.DatasetOption[] options)
public Dataset reload(BigQuery.DatasetOption[] options)
Fetches current dataset's latest information. Returns null if the dataset does not
exist.
Example of reloading a dataset.
Dataset latestDataset = dataset.reload();
if (latestDataset == null) {
// The dataset was not found
}
Parameter
Name
Description
options
DatasetOption[]
dataset options
Returns
Type
Description
Dataset
a Dataset object with latest information or null if not found
toBuilder()
public Dataset.Builder toBuilder()
Returns a builder for the dataset object.
Returns
Type
Description
Dataset.Builder
Overrides
update(BigQuery.DatasetOption[] options)
public Dataset update(BigQuery.DatasetOption[] options)
Updates the dataset's information with this dataset's information. Dataset's user-defined id
cannot be changed. A new Dataset object is returned.
Example of updating a dataset.
String friendlyName = "my_friendly_name";
Builder builder = dataset.toBuilder();
builder.setFriendlyName(friendlyName);
Dataset updatedDataset = builder.build().update();
Parameter
Name
Description
options
DatasetOption[]
dataset options
Returns
Type
Description
Dataset
a Dataset object with updated information
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-10-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-06 UTC."],[],[]]