// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.biglake.hive.v1beta;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

option go_package = "cloud.google.com/go/biglake/hive/apiv1beta/hivepb;hivepb";
option java_multiple_files = true;
option java_outer_classname = "HiveMetastoreProto";
option java_package = "com.google.cloud.biglake.hive.v1beta";

// Hive Metastore Service is a biglake service that allows users to manage
// their external Hive catalogs. Full API compatibility with OSS Hive Metastore
// APIs is not supported. The methods match the Hive Metastore API spec mostly
// except for a few exceptions.
// These include listing resources with pattern,
// environment context which are combined in a single List API, return of
// ListResponse object instead of a list of resources, transactions, locks, etc.
//
// The BigLake Hive Metastore API defines the following resources:
//
// * A collection of Google Cloud projects: `/projects/*`
// * Each project has a collection of catalogs: `/catalogs/*`
// * Each catalog has a collection of databases: `/databases/*`
// * Each database has a collection of tables: `/tables/*`
service HiveMetastoreService {
  option (google.api.default_host) = "biglake.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/bigquery,"
      "https://www.googleapis.com/auth/cloud-platform";

  // Creates a new hive catalog.
  rpc CreateHiveCatalog(CreateHiveCatalogRequest) returns (HiveCatalog) {
    option (google.api.http) = {
      post: "/hive/v1beta/{parent=projects/*}/catalogs"
      body: "hive_catalog"
    };
    option (google.api.method_signature) =
        "parent,hive_catalog,hive_catalog_id";
  }

  // Gets the catalog specified by the resource name.
  rpc GetHiveCatalog(GetHiveCatalogRequest) returns (HiveCatalog) {
    option (google.api.http) = {
      get: "/hive/v1beta/{name=projects/*/catalogs/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // List all catalogs in a specified project.
  rpc ListHiveCatalogs(ListHiveCatalogsRequest)
      returns (ListHiveCatalogsResponse) {
    option (google.api.http) = {
      get: "/hive/v1beta/{parent=projects/*}/catalogs"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates an existing catalog.
  rpc UpdateHiveCatalog(UpdateHiveCatalogRequest) returns (HiveCatalog) {
    option (google.api.http) = {
      patch: "/hive/v1beta/{hive_catalog.name=projects/*/catalogs/*}"
      body: "hive_catalog"
    };
    option (google.api.method_signature) = "hive_catalog,update_mask";
  }

  // Deletes an existing catalog specified by the catalog ID. Delete will fail
  // if the catalog is not empty.
  rpc DeleteHiveCatalog(DeleteHiveCatalogRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/hive/v1beta/{name=projects/*/catalogs/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates a new database.
  rpc CreateHiveDatabase(CreateHiveDatabaseRequest) returns (HiveDatabase) {
    option (google.api.http) = {
      post: "/hive/v1beta/{parent=projects/*/catalogs/*}/databases"
      body: "hive_database"
    };
    option (google.api.method_signature) =
        "parent,hive_database,hive_database_id";
  }

  // Gets the database specified by the resource name.
  rpc GetHiveDatabase(GetHiveDatabaseRequest) returns (HiveDatabase) {
    option (google.api.http) = {
      get: "/hive/v1beta/{name=projects/*/catalogs/*/databases/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // List all databases in a specified catalog.
  rpc ListHiveDatabases(ListHiveDatabasesRequest)
      returns (ListHiveDatabasesResponse) {
    option (google.api.http) = {
      get: "/hive/v1beta/{parent=projects/*/catalogs/*}/databases"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates an existing database specified by the database name.
  rpc UpdateHiveDatabase(UpdateHiveDatabaseRequest) returns (HiveDatabase) {
    option (google.api.http) = {
      patch: "/hive/v1beta/{hive_database.name=projects/*/catalogs/*/databases/*}"
      body: "hive_database"
    };
    option (google.api.method_signature) = "hive_database,update_mask";
  }

  // Deletes an existing database specified by the database name.
  rpc DeleteHiveDatabase(DeleteHiveDatabaseRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/hive/v1beta/{name=projects/*/catalogs/*/databases/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates a new hive table.
  rpc CreateHiveTable(CreateHiveTableRequest) returns (HiveTable) {
    option (google.api.http) = {
      post: "/hive/v1beta/{parent=projects/*/catalogs/*/databases/*}/tables"
      body: "hive_table"
    };
    option (google.api.method_signature) = "parent,hive_table,hive_table_id";
  }

  // Gets the table specified by the resource name.
  rpc GetHiveTable(GetHiveTableRequest) returns (HiveTable) {
    option (google.api.http) = {
      get: "/hive/v1beta/{name=projects/*/catalogs/*/databases/*/tables/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // List all hive tables in a specified project under the hive catalog and
  // database.
  rpc ListHiveTables(ListHiveTablesRequest) returns (ListHiveTablesResponse) {
    option (google.api.http) = {
      get: "/hive/v1beta/{parent=projects/*/catalogs/*/databases/*}/tables"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates an existing table specified by the table name.
  rpc UpdateHiveTable(UpdateHiveTableRequest) returns (HiveTable) {
    option (google.api.http) = {
      patch: "/hive/v1beta/{hive_table.name=projects/*/catalogs/*/databases/*/tables/*}"
      body: "hive_table"
    };
    option (google.api.method_signature) = "hive_table,update_mask";
  }

  // Deletes an existing table specified by the table name.
  rpc DeleteHiveTable(DeleteHiveTableRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/hive/v1beta/{name=projects/*/catalogs/*/databases/*/tables/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Adds partitions to a table.
  rpc BatchCreatePartitions(BatchCreatePartitionsRequest)
      returns (BatchCreatePartitionsResponse) {
    option (google.api.http) = {
      post: "/hive/v1beta/{parent=projects/*/catalogs/*/databases/*/tables/*}/partitions:batchCreate"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
  }

  // Deletes partitions from a table.
  rpc BatchDeletePartitions(BatchDeletePartitionsRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/hive/v1beta/{parent=projects/*/catalogs/*/databases/*/tables/*}/partitions:batchDelete"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates partitions in a table.
  rpc BatchUpdatePartitions(BatchUpdatePartitionsRequest)
      returns (BatchUpdatePartitionsResponse) {
    option (google.api.http) = {
      post: "/hive/v1beta/{parent=projects/*/catalogs/*/databases/*/tables/*}/partitions:batchUpdate"
      body: "*"
    };
    option (google.api.method_signature) = "parent";
  }

  // Streams list of partitions from a table.
  rpc ListPartitions(ListPartitionsRequest)
      returns (stream ListPartitionsResponse) {
    option (google.api.http) = {
      get: "/hive/v1beta/{parent=projects/*/catalogs/*/databases/*/tables/*}/partitions:list"
    };
    option (google.api.method_signature) = "parent";
  }
}

// The HiveCatalog contains spark/hive databases and tables in the BigLake
// Metastore. While creating resources under a catalog, ideally ensure that the
// storage bucket location, spark / hive engine location or any other compute
// location  match. Catalog can be viewed as the destination for migrating an
// on-prem Hive metastore to GCP.
message HiveCatalog {
  option (google.api.resource) = {
    type: "biglake.googleapis.com/Catalog"
    pattern: "projects/{project}/catalogs/{catalog}"
    plural: "catalogs"
    singular: "catalog"
  };

  // The replica of the Catalog.
  message Replica {
    // If the catalog is replicated to multiple regions, this enum describes the
    // current state of the replica.
    enum State {
      // The replica state is unknown.
      STATE_UNSPECIFIED = 0;

      // Indicates the replica is the writable primary.
      STATE_PRIMARY = 1;

      // Indicates the replica has been recently assigned as the primary, but
      // not all databases are writeable yet.
      STATE_PRIMARY_IN_PROGRESS = 2;

      // Indicates the replica is a read-only secondary replica.
      STATE_SECONDARY = 3;
    }

    // Output only. The region of the replica. For example `us-east1`.
    string region = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The current state of the replica.
    State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // Output only. The resource name.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}
  string name = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Catalog" }
  ];

  // Optional. Stores the catalog description.
  // The maximum length is 4000 characters.
  string description = 2 [(google.api.field_behavior) = OPTIONAL];

  // Required. The Cloud Storage location path where the catalog exists.
  // Format: gs://bucket/path/to/catalog
  // The maximum length is 4000 characters.
  string location_uri = 3 [(google.api.field_behavior) = REQUIRED];

  // Output only. The replicas for the catalog metadata.
  repeated Replica replicas = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for the CreateHiveCatalog method.
message CreateHiveCatalogRequest {
  // Required. The parent resource where this catalog will be created.
  // Format: projects/{project_id_or_number}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudresourcemanager.googleapis.com/Project"
    }
  ];

  // Required. The catalog to create.
  // The `name` field does not need to be provided. Gets copied over from
  // catalog_id.
  HiveCatalog hive_catalog = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The Hive Catalog ID to use for the catalog that will become the
  // final component of the catalog's resource name. The maximum length is 256
  // characters.
  string hive_catalog_id = 3 [(google.api.field_behavior) = REQUIRED];

  // Required. The GCP region that specifies where the catalog metadata is
  // stored, e.g. us-central1, EU, etc.
  string primary_location = 4
      [json_name = "primary_location", (google.api.field_behavior) = REQUIRED];
}

// Request message for the GetHiveCatalog method.
message GetHiveCatalogRequest {
  // Required. The name of the catalog to retrieve.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Catalog" }
  ];
}

// Request message for the ListHiveCatalogs method.
message ListHiveCatalogsRequest {
  // Required. The project to list catalogs from.
  // Format: projects/{project_id_or_number}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudresourcemanager.googleapis.com/Project"
    }
  ];

  // Optional. Page size for pagination.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Page token for pagination.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for the ListHiveCatalogs method.
message ListHiveCatalogsResponse {
  // Output only. The catalogs from the specified project.
  repeated HiveCatalog catalogs = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. A token, which can be sent as `page_token` to retrieve the
  // next page. If this field is omitted, there are no subsequent pages.
  string next_page_token = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The list of unreachable cloud regions. If non-empty, the
  // result set might be incomplete.
  repeated string unreachable = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for the UpdateHiveCatalog method.
message UpdateHiveCatalogRequest {
  // Required. The hive catalog to update.
  // The name under the catalog is used to identify the catalog.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}
  HiveCatalog hive_catalog = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The list of fields to update.
  //
  // For the `FieldMask` definition, see
  // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
  // If not set, defaults to all of the fields that are allowed to update.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for the DeleteHiveCatalog method.
message DeleteHiveCatalogRequest {
  // Required. The name of the catalog to delete.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Catalog" }
  ];
}

// Stores the hive database information. It includes the database name,
// description, location and properties associated with the database.
message HiveDatabase {
  option (google.api.resource) = {
    type: "biglake.googleapis.com/Namespace"
    pattern: "projects/{project}/catalogs/{catalog}/databases/{database}"
    plural: "namespaces"
    singular: "namespace"
  };

  // Output only. The resource name.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}
  string name = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "biglake.googleapis.com/Namespace"
    }
  ];

  // Optional. Stores the database description.
  // The maximum length is 4000 characters.
  string description = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The Cloud Storage location path where the database exists.
  // Format: `gs://bucket/path/to/database`
  // If unspecified, the database will be stored in the catalog location.
  // The maximum length is 4000 characters.
  string location_uri = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Stores the properties associated with the database.
  // The maximum size is 2 MiB.
  map<string, string> parameters = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for the CreateHiveDatabase method.
message CreateHiveDatabaseRequest {
  // Required. The parent resource where this database will be created.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Catalog" }
  ];

  // Required. The database to create.
  // The `name` field does not need to be provided.
  HiveDatabase hive_database = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The ID to use for the Hive Database.
  // The maximum length is 128 characters.
  string hive_database_id = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request message for the GetHiveDatabase method.
message GetHiveDatabaseRequest {
  // Required. The name of the database to retrieve.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "biglake.googleapis.com/Namespace"
    }
  ];
}

// Request message for the ListHiveDatabases method.
message ListHiveDatabasesRequest {
  // Required. The hive catalog to list databases from.
  // Format: projects/{project_id_or_number}/catalogs/{catalog_id}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Catalog" }
  ];

  // Optional. Page size for pagination.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. PageToken for pagination.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for the ListHiveDatabases method.
message ListHiveDatabasesResponse {
  // Output only. The databases from the specified project and catalog.
  repeated HiveDatabase databases = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. A token, which can be sent as `page_token` to retrieve the
  // next page. If this field is omitted, there are no subsequent pages.
  string next_page_token = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for the UpdateHiveDatabase method.
message UpdateHiveDatabaseRequest {
  // Required. The database to update.
  //
  // The database's `name` field is used to identify the database to update.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}
  HiveDatabase hive_database = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The list of fields to update.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for the DeleteHiveDatabase method.
message DeleteHiveDatabaseRequest {
  // Required. The name of the database to delete.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "biglake.googleapis.com/Namespace"
    }
  ];
}

// Stores the hive table information. It includes the table name, schema (column
// names and types), data location, storage format, serde info, etc. This
// message closely matches the Table object in the IMetastoreClient
message HiveTable {
  option (google.api.resource) = {
    type: "biglake.googleapis.com/Table"
    pattern: "projects/{project}/catalogs/{catalog}/databases/{database}/tables/{table}"
    plural: "tables"
    singular: "table"
  };

  // Output only. The resource name.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id}
  string name = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];

  // Optional. Description of the table. The maximum length is 4000 characters.
  string description = 2 [(google.api.field_behavior) = OPTIONAL];

  // Required. Storage descriptor of the table.
  StorageDescriptor storage_descriptor = 3
      [(google.api.field_behavior) = REQUIRED];

  // Output only. The creation time of the table.
  google.protobuf.Timestamp create_time = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The partition keys of the table.
  repeated FieldSchema partition_keys = 7
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Stores the properties associated with the table. The maximum size
  // is 4MiB.
  map<string, string> parameters = 8 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The type of the table. This is EXTERNAL for BigLake hive
  // tables.
  string table_type = 11 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Field schema information.
message FieldSchema {
  // Required. Name of the field. The maximum length is 767 characters.
  string name = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Type of the field. The maximum length is 128 characters.
  string type = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Comment of the field. The maximum length is 256 characters.
  string comment = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Contains information about the physical storage of the table data.
message StorageDescriptor {
  // Sort order of the stored data per column.
  message Order {
    // Required. The column name. The maximum length is 767 characters.
    string col = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. Defines the sort order of the column. Ascending if 1,
    // descending if 0.
    int32 order = 2 [(google.api.field_behavior) = REQUIRED];
  }

  // Stores all the information about skewed table.
  message SkewedInfo {
    // The skewed column values.
    message SkewedColumnValue {
      // Required. The skewed column values. The maximum length is 256
      // characters per value.
      repeated string values = 1 [(google.api.field_behavior) = REQUIRED];
    }

    // The skewed key values and their corresponding location.
    message SkewedKeyValuesLocation {
      // Required. The skewed column values. The maximum length is 256
      // characters per value.
      repeated string values = 1 [(google.api.field_behavior) = REQUIRED];

      // Required. The location of the skewed column values. The maximum length
      // is 4000 characters.
      string location = 2 [(google.api.field_behavior) = REQUIRED];
    }

    // Required. The column names that are skewed. The maximum length is 256
    // characters per column name.
    repeated string skewed_col_names = 1
        [(google.api.field_behavior) = REQUIRED];

    // Required. The skewed column values.
    repeated SkewedColumnValue skewed_col_values = 2
        [(google.api.field_behavior) = REQUIRED];

    // Required. The skewed key values locations.
    repeated SkewedKeyValuesLocation skewed_key_values_locations = 3
        [(google.api.field_behavior) = REQUIRED];
  }

  // Required. Specifies the columns of the table.
  repeated FieldSchema columns = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The Cloud storage uri where the table is located.
  // Defaults to `<database_location_uri>/<table_name>`. The maximum length is
  // 4000 characters.
  string location_uri = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The fully qualified Java class name of the input format. The
  // maximum length is 4000 characters.
  string input_format = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The fully qualified Java class name of the output format. The
  // maximum length is 4000 characters.
  string output_format = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Whether the table is compressed.
  optional bool compressed = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The number of buckets in the table.
  optional int32 num_buckets = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Serialization and deserialization information.
  SerdeInfo serde_info = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Reducer grouping columns and clustering columns and bucketing
  // columns
  repeated string bucket_cols = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Sort order of the data in each bucket
  repeated Order sort_cols = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Key-value pairs for the storage descriptor. The maximum size is
  // 10Kib.
  map<string, string> parameters = 10 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Table data skew information.
  SkewedInfo skewed_info = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Whether the table is stored as sub directories.
  optional bool stored_as_sub_dirs = 12
      [(google.api.field_behavior) = OPTIONAL];
}

// Serialization and deserialization information.
message SerdeInfo {
  // The serde types.
  enum SerdeType {
    // The serde type is not specified.
    SERDE_TYPE_UNSPECIFIED = 0;

    // Hive.
    HIVE = 1;

    // Schema registry.
    SCHEMA_REGISTRY = 2;
  }

  // Required. Name of the SerDe. Table name by default. The maximum length is
  // 128 characters.
  string name = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The fully qualified Java class name of the serialization library.
  // The maximum length is 4000 characters.
  string serialization_lib = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Description of the serde. The maximum length is 4000 characters.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Parameters of the serde. The maximum size is 10Kib.
  map<string, string> parameters = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The fully qualified Java class name of the serializer. The
  // maximum length is 4000 characters.
  string serializer_class = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The fully qualified Java class name of the deserializer. The
  // maximum length is 4000 characters.
  string deserializer_class = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The serde type.
  SerdeType serde_type = 7 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for the CreateHiveTable method.
message CreateHiveTableRequest {
  // Required. The parent resource for the table to be created.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "biglake.googleapis.com/Namespace"
    }
  ];

  // Required. The Hive Table to create.
  // The `name` field does not need to be provided.
  HiveTable hive_table = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The Hive Table ID to use for the table that will become the final
  // component of the table's resource name. The maximum length is 256
  // characters.
  string hive_table_id = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request message for the GetHiveTable method.
message GetHiveTableRequest {
  // Required. The name of the table to retrieve.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];
}

// Request message for the ListHiveTables method.
message ListHiveTablesRequest {
  // Required. The database to list tables from.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "biglake.googleapis.com/Namespace"
    }
  ];

  // Optional. Page size for pagination.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. PageToken for pagination.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for the ListHiveTables method.
message ListHiveTablesResponse {
  // Output only. The tables from the specified project, catalog and database.
  repeated HiveTable tables = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. A token, which can be sent as `page_token` to retrieve the
  // next page. If this field is omitted, there are no subsequent pages.
  string next_page_token = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for the UpdateHiveTable method.
message UpdateHiveTableRequest {
  // Required. The table to update.
  //
  // The table's `name` field is used to identify the table to update.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id}
  HiveTable hive_table = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The list of fields to update.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for the DeleteHiveTable method.
message DeleteHiveTableRequest {
  // Required. The name of the database to delete.
  // Format:
  // projects/{project_id_or_number}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];
}

// Information about a Hive partition.
message Partition {
  // Required. Represents the values of the partition keys, where each value
  // corresponds to a specific partition key in the order in which the keys are
  // defined. Each value is limited to 1024 characters.
  repeated string values = 1 [(google.api.field_behavior) = REQUIRED];

  // Output only. The creation time of the partition.
  google.protobuf.Timestamp create_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Contains information about the physical storage of the data in
  // the partition.
  StorageDescriptor storage_descriptor = 3
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Additional parameters or metadata associated with the partition.
  // Maximum size 10 KiB.
  map<string, string> parameters = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. List of columns.
  repeated FieldSchema fields = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Represents the values of a partition.
message PartitionValues {
  // Required. The values of the partition keys, where each value corresponds to
  // a specific partition key in the order in which the keys are defined.
  repeated string values = 1 [(google.api.field_behavior) = REQUIRED];
}

// Request message for CreatePartition. The Partition is
// uniquely identified by values, which is an ordered list. Hence, there is no
// separate name or partition id field.
message CreatePartitionRequest {
  // Required. Reference to the table to where the partition to be added, in the
  // format of
  // projects/{project}/catalogs/{catalogs}/databases/{databases}/tables/{table}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];

  // Required. The partition to be added.
  Partition partition = 2 [(google.api.field_behavior) = REQUIRED];
}

// Request message for the BatchCreatePartitions method.
message BatchCreatePartitionsRequest {
  // Required. Reference to the table to where the partitions to be added, in
  // the format of
  // projects/{project}/catalogs/{catalogs}/databases/{database}/tables/{table}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];

  // Required. Requests to add partitions to the table.
  repeated CreatePartitionRequest requests = 2
      [(google.api.field_behavior) = REQUIRED];

  // Optional. Corresponds to the `ifNotExists` flag in the Hive Metastore APIs.
  // If the flag is set to false, the server will return ALREADY_EXISTS if any
  // partition already exists. If the flag is set to true, the server will skip
  // existing partitions and insert only the non-existing partitions.
  // A maximum of 900 partitions can be inserted in a batch.
  bool skip_existing_partitions = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for BatchCreatePartitions.
message BatchCreatePartitionsResponse {
  // The list of partitions that have been added.
  repeated Partition partitions = 1;
}

// Request message for BatchDeletePartitions. The Partition is
// uniquely identified by values, which is an ordered list. Hence, there is no
// separate name or partition id field.
message BatchDeletePartitionsRequest {
  // Required. Reference to the table to which these partitions belong, in the
  // format of
  // projects/{project}/catalogs/{catalogs}/databases/{database}/tables/{table}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];

  // Required. The list of partitions (identified by its values) to be deleted.
  // A maximum of 900 partitions can be deleted in a batch.
  repeated PartitionValues partition_values = 2
      [(google.api.field_behavior) = REQUIRED];
}

// Request message for UpdatePartition.
message UpdatePartitionRequest {
  // Required. The partition to be updated.
  Partition partition = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The list of fields to update.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for BatchUpdatePartitions.
message BatchUpdatePartitionsRequest {
  // Required. Reference to the table to which these partitions belong, in the
  // format of
  // projects/{project}/catalogs/{catalogs}/databases/{database}/tables/{table}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];

  // Required. Requests to update partitions in the table.
  repeated UpdatePartitionRequest requests = 2
      [(google.api.field_behavior) = REQUIRED];
}

// Response message for BatchUpdatePartitions.
message BatchUpdatePartitionsResponse {
  // The list of partitions that have been updated.
  // A maximum of 900 partitions can be updated in a batch.
  repeated Partition partitions = 1;
}

// Request message for ListPartitions.
message ListPartitionsRequest {
  // Required. Reference to the table to which these partitions belong, in the
  // format of
  // projects/{project}/catalogs/{catalogs}/databases/{database}/tables/{table}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "biglake.googleapis.com/Table" }
  ];

  // Optional. SQL text filtering statement, similar to a `WHERE` clause in a
  // query. Only supports single-row expressions.  Aggregate functions are not
  // supported.
  //
  // Examples:
  // * `"int_field > 5"`
  // * `"date_field = CAST('2014-9-27' as DATE)"`
  // * `"nullable_field is not NULL"`
  // * `"st_equals(geo_field, st_geofromtext("POINT(2, 2)"))"`
  // * `"numeric_field BETWEEN 1.0 AND 5.0"`
  //
  // Restricted to a maximum length of 1 MB.
  string filter = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for ListPartitions.
message ListPartitionsResponse {
  // Output only. List of partitions.
  repeated Partition partitions = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}
