Class BigQueryServicesImpl.DatasetServiceImpl
- All Implemented Interfaces:
AutoCloseable
,BigQueryServices.DatasetService
- Enclosing class:
BigQueryServicesImpl
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.beam.sdk.io.gcp.bigquery.BigQueryServices.DatasetService
BigQueryServices.DatasetService.TableMetadataView
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
createDataset
(String projectId, String datasetId, @Nullable String location, @Nullable String description, @Nullable Long defaultTableExpirationMs) Create aDataset
with the givenlocation
,description
and default expiration time for tables in the dataset (ifnull
, tables don't expire).void
createTable
(Table table) Creates the specified table if it does not exist.void
deleteDataset
(String projectId, String datasetId) Deletes the dataset specified by the datasetId value.void
deleteTable
(TableReference tableRef) Deletes the table specified by tableId from the dataset.getDataset
(String projectId, String datasetId) Gets the specifiedDataset
resource by dataset ID.protected static @Nullable GoogleJsonError.ErrorInfo
getTable
(TableReference tableRef) Gets the specifiedTable
resource by table ID.getTable
(TableReference tableRef, List<String> selectedFields) getTable
(TableReference tableRef, List<String> selectedFields, BigQueryServices.DatasetService.TableMetadataView view) <T> long
insertAll
(TableReference ref, List<FailsafeValueInSingleWindow<TableRow, TableRow>> rowList, @Nullable List<String> insertIdList, InsertRetryPolicy retryPolicy, List<ValueInSingleWindow<T>> failedInserts, ErrorContainer<T> errorContainer, boolean skipInvalidRows, boolean ignoreUnknownValues, boolean ignoreInsertIds, List<ValueInSingleWindow<TableRow>> successfulRows) InsertsTableRows
with the specified insertIds if not null.boolean
isTableEmpty
(TableReference tableRef) Returns true if the table is empty.patchTableDescription
(TableReference tableReference, @Nullable String tableDescription) Patch BigQueryTable
description.
-
Constructor Details
-
DatasetServiceImpl
-
-
Method Details
-
getTable
Gets the specifiedTable
resource by table ID.Returns null if the table is not found.
Tries executing the RPC for at most
MAX_RPC_RETRIES
times until it succeeds.- Specified by:
getTable
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if it exceedsMAX_RPC_RETRIES
attempts.InterruptedException
-
getTable
public @Nullable Table getTable(TableReference tableRef, List<String> selectedFields) throws IOException, InterruptedException - Specified by:
getTable
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
InterruptedException
-
getTable
public @Nullable Table getTable(TableReference tableRef, List<String> selectedFields, BigQueryServices.DatasetService.TableMetadataView view) throws IOException, InterruptedException - Specified by:
getTable
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
InterruptedException
-
createTable
Creates the specified table if it does not exist.If a table with the same name already exists in the dataset, the function simply returns. In such a case, the existing table doesn't necessarily have the same schema as specified by the parameter.
- Specified by:
createTable
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if other error than already existing table occurs.InterruptedException
-
deleteTable
Deletes the table specified by tableId from the dataset. If the table contains data, all the data will be deleted.Tries executing the RPC for at most
MAX_RPC_RETRIES
times until it succeeds.- Specified by:
deleteTable
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if it exceedsMAX_RPC_RETRIES
attempts.InterruptedException
-
isTableEmpty
Description copied from interface:BigQueryServices.DatasetService
Returns true if the table is empty.- Specified by:
isTableEmpty
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if the table is not found.InterruptedException
-
getDataset
public Dataset getDataset(String projectId, String datasetId) throws IOException, InterruptedException Gets the specifiedDataset
resource by dataset ID.Tries executing the RPC for at most
MAX_RPC_RETRIES
times until it succeeds.- Specified by:
getDataset
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if it exceedsMAX_RPC_RETRIES
attempts.InterruptedException
-
createDataset
public void createDataset(String projectId, String datasetId, @Nullable String location, @Nullable String description, @Nullable Long defaultTableExpirationMs) throws IOException, InterruptedException Create aDataset
with the givenlocation
,description
and default expiration time for tables in the dataset (ifnull
, tables don't expire).Tries executing the RPC for at most
MAX_RPC_RETRIES
times until it succeeds.- Specified by:
createDataset
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if it exceedsMAX_RPC_RETRIES
attempts.InterruptedException
-
deleteDataset
public void deleteDataset(String projectId, String datasetId) throws IOException, InterruptedException Deletes the dataset specified by the datasetId value.Before you can delete a dataset, you must delete all its tables.
Tries executing the RPC for at most
MAX_RPC_RETRIES
times until it succeeds.- Specified by:
deleteDataset
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
- if it exceedsMAX_RPC_RETRIES
attempts.InterruptedException
-
insertAll
public <T> long insertAll(TableReference ref, List<FailsafeValueInSingleWindow<TableRow, TableRow>> rowList, @Nullable List<String> insertIdList, InsertRetryPolicy retryPolicy, List<ValueInSingleWindow<T>> failedInserts, ErrorContainer<T> errorContainer, boolean skipInvalidRows, boolean ignoreUnknownValues, boolean ignoreInsertIds, List<ValueInSingleWindow<TableRow>> successfulRows) throws IOException, InterruptedExceptionDescription copied from interface:BigQueryServices.DatasetService
InsertsTableRows
with the specified insertIds if not null.If any insert fail permanently according to the retry policy, those rows are added to failedInserts.
Returns the total bytes count of
TableRows
.- Specified by:
insertAll
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
InterruptedException
-
getErrorInfo
-
patchTableDescription
public Table patchTableDescription(TableReference tableReference, @Nullable String tableDescription) throws IOException, InterruptedException Description copied from interface:BigQueryServices.DatasetService
Patch BigQueryTable
description.- Specified by:
patchTableDescription
in interfaceBigQueryServices.DatasetService
- Throws:
IOException
InterruptedException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-