Class MetastorePartitionServiceClient (3.9.0)

GitHub RepositoryProduct Reference

Service Description: BigQuery Metastore Partition Service API. This service is used for managing metastore partitions in BigQuery metastore. The service supports only batch operations for write.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchCreateMetastorePartitionsRequest request =
       BatchCreateMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllRequests(new ArrayList<CreateMetastorePartitionRequest>())
           .setSkipExistingPartitions(true)
           .build();
   BatchCreateMetastorePartitionsResponse response =
       metastorePartitionServiceClient.batchCreateMetastorePartitions(request);
 }
 

Note: close() needs to be called on the MetastorePartitionServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

BatchCreateMetastorePartitions

Adds metastore partitions to a table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • batchCreateMetastorePartitions(BatchCreateMetastorePartitionsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • batchCreateMetastorePartitionsCallable()

BatchDeleteMetastorePartitions

Deletes metastore partitions from a table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • batchDeleteMetastorePartitions(BatchDeleteMetastorePartitionsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • batchDeleteMetastorePartitionsCallable()

BatchUpdateMetastorePartitions

Updates metastore partitions in a table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • batchUpdateMetastorePartitions(BatchUpdateMetastorePartitionsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • batchUpdateMetastorePartitionsCallable()

ListMetastorePartitions

Gets metastore partitions from a table.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listMetastorePartitions(ListMetastorePartitionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listMetastorePartitions(TableName parent)

  • listMetastorePartitions(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listMetastorePartitionsCallable()

StreamMetastorePartitions

This is a bi-di streaming rpc method that allows the client to send a stream of partitions and commit all of them atomically at the end. If the commit is successful, the server will return a response and close the stream. If the commit fails (due to duplicate partitions or other reason), the server will close the stream with an error. This method is only available via the gRPC API (not REST).

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • streamMetastorePartitionsCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of MetastorePartitionServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 MetastorePartitionServiceSettings metastorePartitionServiceSettings =
     MetastorePartitionServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create(metastorePartitionServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 MetastorePartitionServiceSettings metastorePartitionServiceSettings =
     MetastorePartitionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create(metastorePartitionServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > MetastorePartitionServiceClient

Static Methods

create()

public static final MetastorePartitionServiceClient create()

Constructs an instance of MetastorePartitionServiceClient with default settings.

Returns
Type Description
MetastorePartitionServiceClient
Exceptions
Type Description
IOException

create(MetastorePartitionServiceSettings settings)

public static final MetastorePartitionServiceClient create(MetastorePartitionServiceSettings settings)

Constructs an instance of MetastorePartitionServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings MetastorePartitionServiceSettings
Returns
Type Description
MetastorePartitionServiceClient
Exceptions
Type Description
IOException

create(MetastorePartitionServiceStub stub)

public static final MetastorePartitionServiceClient create(MetastorePartitionServiceStub stub)

Constructs an instance of MetastorePartitionServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(MetastorePartitionServiceSettings).

Parameter
Name Description
stub MetastorePartitionServiceStub
Returns
Type Description
MetastorePartitionServiceClient

Constructors

MetastorePartitionServiceClient(MetastorePartitionServiceSettings settings)

protected MetastorePartitionServiceClient(MetastorePartitionServiceSettings settings)

Constructs an instance of MetastorePartitionServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings MetastorePartitionServiceSettings

MetastorePartitionServiceClient(MetastorePartitionServiceStub stub)

protected MetastorePartitionServiceClient(MetastorePartitionServiceStub stub)
Parameter
Name Description
stub MetastorePartitionServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

batchCreateMetastorePartitions(BatchCreateMetastorePartitionsRequest request)

public final BatchCreateMetastorePartitionsResponse batchCreateMetastorePartitions(BatchCreateMetastorePartitionsRequest request)

Adds metastore partitions to a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchCreateMetastorePartitionsRequest request =
       BatchCreateMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllRequests(new ArrayList<CreateMetastorePartitionRequest>())
           .setSkipExistingPartitions(true)
           .build();
   BatchCreateMetastorePartitionsResponse response =
       metastorePartitionServiceClient.batchCreateMetastorePartitions(request);
 }
 
Parameter
Name Description
request BatchCreateMetastorePartitionsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
BatchCreateMetastorePartitionsResponse

batchCreateMetastorePartitionsCallable()

public final UnaryCallable<BatchCreateMetastorePartitionsRequest,BatchCreateMetastorePartitionsResponse> batchCreateMetastorePartitionsCallable()

Adds metastore partitions to a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchCreateMetastorePartitionsRequest request =
       BatchCreateMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllRequests(new ArrayList<CreateMetastorePartitionRequest>())
           .setSkipExistingPartitions(true)
           .build();
   ApiFuture<BatchCreateMetastorePartitionsResponse> future =
       metastorePartitionServiceClient
           .batchCreateMetastorePartitionsCallable()
           .futureCall(request);
   // Do something.
   BatchCreateMetastorePartitionsResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<BatchCreateMetastorePartitionsRequest,BatchCreateMetastorePartitionsResponse>

batchDeleteMetastorePartitions(BatchDeleteMetastorePartitionsRequest request)

public final void batchDeleteMetastorePartitions(BatchDeleteMetastorePartitionsRequest request)

Deletes metastore partitions from a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchDeleteMetastorePartitionsRequest request =
       BatchDeleteMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllPartitionValues(new ArrayList<MetastorePartitionValues>())
           .build();
   metastorePartitionServiceClient.batchDeleteMetastorePartitions(request);
 }
 
Parameter
Name Description
request BatchDeleteMetastorePartitionsRequest

The request object containing all of the parameters for the API call.

batchDeleteMetastorePartitionsCallable()

public final UnaryCallable<BatchDeleteMetastorePartitionsRequest,Empty> batchDeleteMetastorePartitionsCallable()

Deletes metastore partitions from a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchDeleteMetastorePartitionsRequest request =
       BatchDeleteMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllPartitionValues(new ArrayList<MetastorePartitionValues>())
           .build();
   ApiFuture<Empty> future =
       metastorePartitionServiceClient
           .batchDeleteMetastorePartitionsCallable()
           .futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<BatchDeleteMetastorePartitionsRequest,Empty>

batchUpdateMetastorePartitions(BatchUpdateMetastorePartitionsRequest request)

public final BatchUpdateMetastorePartitionsResponse batchUpdateMetastorePartitions(BatchUpdateMetastorePartitionsRequest request)

Updates metastore partitions in a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchUpdateMetastorePartitionsRequest request =
       BatchUpdateMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllRequests(new ArrayList<UpdateMetastorePartitionRequest>())
           .build();
   BatchUpdateMetastorePartitionsResponse response =
       metastorePartitionServiceClient.batchUpdateMetastorePartitions(request);
 }
 
Parameter
Name Description
request BatchUpdateMetastorePartitionsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
BatchUpdateMetastorePartitionsResponse

batchUpdateMetastorePartitionsCallable()

public final UnaryCallable<BatchUpdateMetastorePartitionsRequest,BatchUpdateMetastorePartitionsResponse> batchUpdateMetastorePartitionsCallable()

Updates metastore partitions in a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BatchUpdateMetastorePartitionsRequest request =
       BatchUpdateMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllRequests(new ArrayList<UpdateMetastorePartitionRequest>())
           .build();
   ApiFuture<BatchUpdateMetastorePartitionsResponse> future =
       metastorePartitionServiceClient
           .batchUpdateMetastorePartitionsCallable()
           .futureCall(request);
   // Do something.
   BatchUpdateMetastorePartitionsResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<BatchUpdateMetastorePartitionsRequest,BatchUpdateMetastorePartitionsResponse>

close()

public final void close()

getSettings()

public final MetastorePartitionServiceSettings getSettings()
Returns
Type Description
MetastorePartitionServiceSettings

getStub()

public MetastorePartitionServiceStub getStub()
Returns
Type Description
MetastorePartitionServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listMetastorePartitions(ListMetastorePartitionsRequest request)

public final ListMetastorePartitionsResponse listMetastorePartitions(ListMetastorePartitionsRequest request)

Gets metastore partitions from a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   ListMetastorePartitionsRequest request =
       ListMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .setFilter("filter-1274492040")
           .build();
   ListMetastorePartitionsResponse response =
       metastorePartitionServiceClient.listMetastorePartitions(request);
 }
 
Parameter
Name Description
request ListMetastorePartitionsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ListMetastorePartitionsResponse

listMetastorePartitions(TableName parent)

public final ListMetastorePartitionsResponse listMetastorePartitions(TableName parent)

Gets metastore partitions from a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   TableName parent = TableName.of("[PROJECT]", "[DATASET]", "[TABLE]");
   ListMetastorePartitionsResponse response =
       metastorePartitionServiceClient.listMetastorePartitions(parent);
 }
 
Parameter
Name Description
parent TableName

Required. Reference to the table to which these metastore partitions belong, in the format of projects/{project}/locations/{location}/datasets/{dataset}/tables/{table}.

Returns
Type Description
ListMetastorePartitionsResponse

listMetastorePartitions(String parent)

public final ListMetastorePartitionsResponse listMetastorePartitions(String parent)

Gets metastore partitions from a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   String parent = TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString();
   ListMetastorePartitionsResponse response =
       metastorePartitionServiceClient.listMetastorePartitions(parent);
 }
 
Parameter
Name Description
parent String

Required. Reference to the table to which these metastore partitions belong, in the format of projects/{project}/locations/{location}/datasets/{dataset}/tables/{table}.

Returns
Type Description
ListMetastorePartitionsResponse

listMetastorePartitionsCallable()

public final UnaryCallable<ListMetastorePartitionsRequest,ListMetastorePartitionsResponse> listMetastorePartitionsCallable()

Gets metastore partitions from a table.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   ListMetastorePartitionsRequest request =
       ListMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<ListMetastorePartitionsResponse> future =
       metastorePartitionServiceClient.listMetastorePartitionsCallable().futureCall(request);
   // Do something.
   ListMetastorePartitionsResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ListMetastorePartitionsRequest,ListMetastorePartitionsResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

streamMetastorePartitionsCallable()

public final BidiStreamingCallable<StreamMetastorePartitionsRequest,StreamMetastorePartitionsResponse> streamMetastorePartitionsCallable()

This is a bi-di streaming rpc method that allows the client to send a stream of partitions and commit all of them atomically at the end. If the commit is successful, the server will return a response and close the stream. If the commit fails (due to duplicate partitions or other reason), the server will close the stream with an error. This method is only available via the gRPC API (not REST).

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetastorePartitionServiceClient metastorePartitionServiceClient =
     MetastorePartitionServiceClient.create()) {
   BidiStream<StreamMetastorePartitionsRequest, StreamMetastorePartitionsResponse> bidiStream =
       metastorePartitionServiceClient.streamMetastorePartitionsCallable().call();
   StreamMetastorePartitionsRequest request =
       StreamMetastorePartitionsRequest.newBuilder()
           .setParent(TableName.of("[PROJECT]", "[DATASET]", "[TABLE]").toString())
           .addAllMetastorePartitions(new ArrayList<MetastorePartition>())
           .setSkipExistingPartitions(true)
           .build();
   bidiStream.send(request);
   for (StreamMetastorePartitionsResponse response : bidiStream) {
     // Do something when a response is received.
   }
 }
 
Returns
Type Description
BidiStreamingCallable<StreamMetastorePartitionsRequest,StreamMetastorePartitionsResponse>