Class MetastorePartitionServiceClient

java.lang.Object
com.google.cloud.bigquery.storage.v1beta.MetastorePartitionServiceClient
All Implemented Interfaces:
com.google.api.gax.core.BackgroundResource, AutoCloseable

@BetaApi @Generated("by gapic-generator-java") public class MetastorePartitionServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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)
           .setTraceId("traceId-1067401920")
           .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.

  • Constructor Details

    • MetastorePartitionServiceClient

      protected MetastorePartitionServiceClient(MetastorePartitionServiceSettings settings) throws IOException
      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.
      Throws:
      IOException
    • MetastorePartitionServiceClient

      protected MetastorePartitionServiceClient(MetastorePartitionServiceStub stub)
  • Method Details

    • create

      public static final MetastorePartitionServiceClient create() throws IOException
      Constructs an instance of MetastorePartitionServiceClient with default settings.
      Throws:
      IOException
    • create

      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.
      Throws:
      IOException
    • create

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

      public final MetastorePartitionServiceSettings getSettings()
    • getStub

    • batchCreateMetastorePartitions

      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)
                 .setTraceId("traceId-1067401920")
                 .build();
         BatchCreateMetastorePartitionsResponse response =
             metastorePartitionServiceClient.batchCreateMetastorePartitions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • batchCreateMetastorePartitionsCallable

      public final com.google.api.gax.rpc.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)
                 .setTraceId("traceId-1067401920")
                 .build();
         ApiFuture<BatchCreateMetastorePartitionsResponse> future =
             metastorePartitionServiceClient
                 .batchCreateMetastorePartitionsCallable()
                 .futureCall(request);
         // Do something.
         BatchCreateMetastorePartitionsResponse response = future.get();
       }
       
    • batchDeleteMetastorePartitions

      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>())
                 .setTraceId("traceId-1067401920")
                 .build();
         metastorePartitionServiceClient.batchDeleteMetastorePartitions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • batchDeleteMetastorePartitionsCallable

      public final com.google.api.gax.rpc.UnaryCallable<BatchDeleteMetastorePartitionsRequest,com.google.protobuf.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>())
                 .setTraceId("traceId-1067401920")
                 .build();
         ApiFuture<Empty> future =
             metastorePartitionServiceClient
                 .batchDeleteMetastorePartitionsCallable()
                 .futureCall(request);
         // Do something.
         future.get();
       }
       
    • batchUpdateMetastorePartitions

      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>())
                 .setTraceId("traceId-1067401920")
                 .build();
         BatchUpdateMetastorePartitionsResponse response =
             metastorePartitionServiceClient.batchUpdateMetastorePartitions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • batchUpdateMetastorePartitionsCallable

      public final com.google.api.gax.rpc.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>())
                 .setTraceId("traceId-1067401920")
                 .build();
         ApiFuture<BatchUpdateMetastorePartitionsResponse> future =
             metastorePartitionServiceClient
                 .batchUpdateMetastorePartitionsCallable()
                 .futureCall(request);
         // Do something.
         BatchUpdateMetastorePartitionsResponse response = future.get();
       }
       
    • listMetastorePartitions

      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);
       }
       
      Parameters:
      parent - Required. Reference to the table to which these metastore partitions belong, in the format of projects/{project}/locations/{location}/datasets/{dataset}/tables/{table}.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • listMetastorePartitions

      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);
       }
       
      Parameters:
      parent - Required. Reference to the table to which these metastore partitions belong, in the format of projects/{project}/locations/{location}/datasets/{dataset}/tables/{table}.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • listMetastorePartitions

      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")
                 .setTraceId("traceId-1067401920")
                 .build();
         ListMetastorePartitionsResponse response =
             metastorePartitionServiceClient.listMetastorePartitions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      com.google.api.gax.rpc.ApiException - if the remote call fails
    • listMetastorePartitionsCallable

      public final com.google.api.gax.rpc.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")
                 .setTraceId("traceId-1067401920")
                 .build();
         ApiFuture<ListMetastorePartitionsResponse> future =
             metastorePartitionServiceClient.listMetastorePartitionsCallable().futureCall(request);
         // Do something.
         ListMetastorePartitionsResponse response = future.get();
       }
       
    • streamMetastorePartitionsCallable

      public final com.google.api.gax.rpc.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.
         }
       }
       
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface com.google.api.gax.core.BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface com.google.api.gax.core.BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface com.google.api.gax.core.BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface com.google.api.gax.core.BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface com.google.api.gax.core.BackgroundResource
      Throws:
      InterruptedException