Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

23.6 KB
Raw Blame
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.

---

paths:

  /metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/statistics:
    parameters:
      - $ref: "./openapi.yaml#/components/parameters/metalake"
      - $ref: "./openapi.yaml#/components/parameters/metadataObjectType"
      - $ref: "./openapi.yaml#/components/parameters/metadataObjectFullName"

    get:
      tags:
        - statistics
      summary: List statistics
      operationId: listStatistics

      responses:
        "200":
            description: Returns the statistics for the specified metadata object
            content:
              application/vnd.gravitino.v1+json:
                schema:
                  $ref: "#/components/responses/StatisticListResponse"
                examples:
                  StatisticListResponse:
                    $ref: "#/components/examples/StatisticListResponse"
        "400":
          $ref: "./openapi.yaml#/components/responses/BadRequestErrorResponse"
        "404":
          description: Not Found - The specified metadata object doesn't exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetadataObjectException:
                  $ref: "#/components/examples/NoSuchMetadataObjectException"
        "501":
          description: Not Implemented - Statistics are not supported for the specified object
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5xx":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    post:
      tags:
        - statistics
      summary: Drop statistics
      operationId: dropStatistics
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StatisticsDropRequest"
            examples:
              StatisticsDropRequest:
                $ref: "#/components/examples/StatisticsDropRequest"

      responses:
        "200":
          $ref: "./openapi.yaml#/components/responses/DropResponse"
        "400":
          description: Bad Request - The object type or statistic names are invalid
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                IllegalStatisticNameException:
                  $ref: "#/components/examples/IllegalStatisticNameException"
        "404":
          description: Not Found - The specified metadata object doesn't exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetadataObjectException:
                  $ref: "#/components/examples/NoSuchMetadataObjectException"
        "409":
          description: Conflict - The specified statistic is unmodifiable or was modified concurrently; the caller decides whether to abort or retry against the current state
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                UnmodifiableStatisticException:
                  $ref: "#/components/examples/UnmodifiableStatisticException"
        "501":
          description: Not Implemented - The requested statistics operation is not supported
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5xx":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    put:
      tags:
        - statistics
      summary: Update statistics
      operationId: updateStatistics
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StatisticsUpdateRequest"
            examples:
              StatisticsUpdateRequest:
                $ref: "#/components/examples/StatisticsUpdateRequest"

      responses:
        "200":
          $ref: "./openapi.yaml#/components/responses/BaseResponse"
        "400":
          description: Bad Request - The object type or statistic names are invalid
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                IllegalStatisticNameException:
                  $ref: "#/components/examples/IllegalStatisticNameException"
        "404":
          description: Not Found - The specified metadata object doesn't exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetadataObjectException:
                  $ref: "#/components/examples/NoSuchMetadataObjectException"
        "409":
          description: Conflict - The specified statistic is unmodifiable or was modified concurrently; the caller decides whether to abort or retry against the current state
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                UnmodifiableStatisticException:
                  $ref: "#/components/examples/UnmodifiableStatisticException"
        "501":
          description: Not Implemented - The requested statistics operation is not supported
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5xx":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

  /metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/statistics/partitions:
    parameters:
      - $ref: "./openapi.yaml#/components/parameters/metalake"
      - $ref: "./openapi.yaml#/components/parameters/metadataObjectType"
      - $ref: "./openapi.yaml#/components/parameters/metadataObjectFullName"

    get:
      tags:
        - partition-statistics
      summary: List partition statistics
      operationId: listPartitionStatistics
      parameters:
        - $ref: "#/components/parameters/from"
        - $ref: "#/components/parameters/to"
        - $ref: "#/components/parameters/fromInclusive"
        - $ref: "#/components/parameters/toInclusive"
      responses:
        "200":
          description: Returns the partition statistics for the specified metadata object
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "#/components/responses/PartitionStatisticsListResponse"
              examples:
                PartitionStatisticsListResponse:
                  $ref: "#/components/examples/PartitionStatisticListResponse"
        "400":
          $ref: "./openapi.yaml#/components/responses/BadRequestErrorResponse"
        "404":
          description: Not Found - The specified metadata object doesn't exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetadataObjectException:
                  $ref: "#/components/examples/NoSuchMetadataObjectException"
        "501":
          description: Not Implemented - Partition statistics are not supported for the specified object
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5xx":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    post:
      tags:
        - partition-statistics
      summary: Drop partition statistics
      operationId: dropPartitionStatistics
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PartitionStatisticsDropRequest"
            examples:
              PartitionStatisticsDropRequest:
                $ref: "#/components/examples/PartitionStatisticsDropRequest"

      responses:
        "200":
          $ref: "./openapi.yaml#/components/responses/DropResponse"
        "400":
          description: Bad Request - The object type or statistic names are invalid
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                IllegalStatisticNameException:
                  $ref: "#/components/examples/IllegalStatisticNameException"
        "404":
          description: Not Found - The specified metadata object doesn't exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetadataObjectException:
                  $ref: "#/components/examples/NoSuchMetadataObjectException"
        "409":
          description: Conflict - The specified statistic is unmodifiable
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                UnmodifiableStatisticException:
                  $ref: "#/components/examples/UnmodifiableStatisticException"
        "501":
          description: Not Implemented - The requested partition statistics operation is not supported
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5xx":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

    put:
      tags:
        - partition-statistics
      summary: Update partition statistics
      operationId: updatePartitionStatistics
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PartitionStatisticsUpdateRequest"
            examples:
              PartitionStatisticUpdateRequest:
                $ref: "#/components/examples/PartitionStatisticUpdateRequest"

      responses:
        "200":
          $ref: "./openapi.yaml#/components/responses/BaseResponse"
        "400":
          description: Bad Request - The object type or statistic names are invalid
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                IllegalStatisticNameException:
                  $ref: "#/components/examples/IllegalStatisticNameException"
        "404":
          description: Not Found - The specified metadata object doesn't exist
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                NoSuchMetadataObjectException:
                  $ref: "#/components/examples/NoSuchMetadataObjectException"
        "409":
          description: Conflict - The specified statistic is unmodifiable
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
              examples:
                UnmodifiableStatisticException:
                  $ref: "#/components/examples/UnmodifiableStatisticException"
        "501":
          description: Not Implemented - The requested partition statistics operation is not supported
          content:
            application/vnd.gravitino.v1+json:
              schema:
                $ref: "./openapi.yaml#/components/schemas/ErrorModel"
        "5xx":
          $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

components:
  parameters:
    from:
      name: from
      in: query
      description: The lower partition name
      required: false
      schema:
        type: string

    to:
      name: to
      in: query
      description: The upper partition name
      required: false
      schema:
        type: string

    fromInclusive:
      name: fromInclusive
      in: query
      description: Whether the lower partition name is inclusive
      required: false
      schema:
        type: boolean

    toInclusive:
      name: toInclusive
      in: query
      description: Whether the upper partition name is inclusive
      required: false
      schema:
        type: boolean

  schemas:
    StatisticsDropRequest:
      type: object
      required:
        - names
      properties:
        names:
          type: array
          items:
            type: string
          description: The names of the statistics to drop for the metadata object

    StatisticsUpdateRequest:
      type: object
      required:
        - updates
      properties:
        updates:
          type: object
          additionalProperties: {}
          description: The statistics to update for each partition

    PartitionStatisticsDropRequest:
      type: object
      required:
        - drops
      properties:
        drops:
          type: array
          items:
            $ref: "#/components/schemas/PartitionStatisticsDrop"
          description: The list of partition statistics to drop

    PartitionStatisticsDrop:
      type: object
      required:
        - partitionName
        - statisticNames
      properties:
        partitionName:
          type: string
          description: The name of the partition
        statisticNames:
          type: array
          items:
            type: string
          description: The names of the statistics to drop for the partition

    PartitionStatisticsUpdateRequest:
      type: object
      required:
        - updates
      properties:
        updates:
          type: array
          items:
            $ref: "#/components/schemas/PartitionStatisticsUpdate"
          description: The list of partition statistics to update

    PartitionStatisticsUpdate:
      type: object
      required:
        - partitionName
        - statistics
      properties:
        partitionName:
          type: string
          description: The name of the partition
        statistics:
          type: object
          additionalProperties: {}
          description: The statistics to update for the partition

    PartitionRange:
      type: object
      properties:
        lowerPartitionName:
          type: string
          description: The lower partition name
        upperPartitionName:
          type: string
          description: The upper partition name
        lowerBoundType:
          type: string
          description: lower bound type
          enum:
            - "CLOSED"
            - "OPEN"
        upperBoundType:
          type: string
          description: upper bound type
          enum:
            - "CLOSED"
            - "OPEN"

    PartitionStatistics:
      type: object
      required:
        - partitionName
        - statistics
      properties:
        partitionName:
          type: string
          description: The name of the partition
        statistics:
          type: array
          items:
            $ref: "#/components/schemas/Statistic"

    Statistic:
      type: object
      required:
        - name
        - reserved
        - modifiable
        - audit
      properties:
        name:
          type: string
          description: The name of the statistic
        value:
          oneOf:
            - type: string
            - type: number
            - type: integer
            - type: boolean
            - type: array
              items: { }
            - type: object
              additionalProperties: { }
          description: >-
            The statistic's value, present only when the statistic has one. Its
            type depends on the statistic — a string, number, integer, boolean,
            array, or object.
        reserved:
          type: boolean
          description: Whether the statistic is reserved
        modifiable:
          type: boolean
          description: Whether the statistic is modifiable
        audit:
          $ref: "./openapi.yaml#/components/schemas/Audit"

  responses:
    StatisticListResponse:
      type: object
      properties:
        code:
          type: integer
          format: int32
          description: Status code of the response
          enum:
            - 0
        statistics:
          type: array
          items:
            $ref: "#/components/schemas/Statistic"

    PartitionStatisticsListResponse:
      type: object
      properties:
        code:
          type: integer
          format: int32
          description: Status code of the response
          enum:
            - 0
        partitionStatistics:
          type: array
          items:
            $ref: "#/components/schemas/PartitionStatistics"
          description: The list of partition statistics results

  examples:
    StatisticsDropRequest:
      value: {
        "names": [ "custom-row_count", "custom-file_size" ]
      }

    StatisticsUpdateRequest:
      value: {
        "updates": {
          "custom-row_count": "1000",
          "custom-file_size": "500MB"
        }
      }

    PartitionStatisticsDropRequest:
      value: {
        "drops": [
          {
            "partitionName": "2023-10-01",
            "statisticNames": [ "custom-row_count", "custom-file_size" ]
          }
        ]
      }

    PartitionStatisticUpdateRequest:
      value: {
        "updates": [
          {
            "partitionName": "2023-10-01",
            "statistics": {
              "custom-row_count": "500",
              "custom-file_size": "250MB"
            }
          }
        ]
      }

    StatisticListResponse:
      value: {
          "code": 0,
          "statistics": [
              {
                "name": "row_count",
                "value": "1000",
                "reserved": true,
                "modifiable": false,
                "audit": {
                  "creator": "user1",
                  "createTime": "2023-10-01T12:00:00Z",
                  "lastModifier": "user2",
                  "lastModifiedTime": "2023-10-02T12:00:00Z"
                }
              },
              {
                "name": "file_size",
                "value": "500MB",
                "reserved": true,
                "modifiable": false,
                "audit": {
                  "creator": "user1",
                  "createTime": "2023-10-01T12:00:00Z",
                  "lastModifier": "user2",
                  "lastModifiedTime": "2023-10-02T12:00:00Z"
                }
              },
              {
                "name": "custom-k1",
                "value": "v1",
                "reserved": false,
                "modifiable": true,
                "audit": {
                  "creator": "user1",
                  "createTime": "2023-10-01T12:00:00Z",
                  "lastModifier": "user2",
                  "lastModifiedTime": "2023-10-02T12:00:00Z"
                }
              }]
      }

    PartitionStatisticListResponse:
      value: {
        "code": 0,
        "partitionStatistics": [
          {
            "partitionName": "p0",
            "statistics": [
              {
                "name": "row_count",
                "value": "1000",
                "reserved": true,
                "modifiable": false,
                "audit": {
                  "creator": "user1",
                  "createTime": "2023-10-01T12:00:00Z",
                  "lastModifier": "user2",
                  "lastModifiedTime": "2023-10-02T12:00:00Z"
                }
              },
              {
                "name": "file_size",
                "value": "500MB",
                "reserved": true,
                "modifiable": false,
                "audit": {
                  "creator": "user1",
                  "createTime": "2023-10-01T12:00:00Z",
                  "lastModifier": "user2",
                  "lastModifiedTime": "2023-10-02T12:00:00Z"
                }
              },
              {
                "name": "custom-k1",
                "value": "v1",
                "reserved": false,
                "modifiable": true,
                "audit": {
                  "creator": "user1",
                  "createTime": "2023-10-01T12:00:00Z",
                  "lastModifier": "user2",
                  "lastModifiedTime": "2023-10-02T12:00:00Z"
                }
              }
            ]
          },
          {
            "partitionName": "p1",
            "statistics": [
             {
               "name": "row_count",
               "value": "2000",
               "reserved": true,
               "modifiable": false,
               "audit": {
                 "creator": "user1",
                 "createTime": "2023-10-01T12:00:00Z",
                 "lastModifier": "user2",
                 "lastModifiedTime": "2023-10-02T12:00:00Z"
               }
             },
             {
               "name": "file_size",
               "value": "1GB",
               "reserved": true,
               "modifiable": false,
               "audit": {
                 "creator": "user1",
                 "createTime": "2023-10-01T12:00:00Z",
                 "lastModifier": "user2",
                 "lastModifiedTime": "2023-10-02T12:00:00Z"
               }
             },
             {
               "name": "custom-k1",
               "value": "v2",
               "reserved": false,
               "modifiable": true,
               "audit": {
                 "creator": "user1",
                 "createTime": "2023-10-01T12:00:00Z",
                 "lastModifier": "user2",
                 "lastModifiedTime": "2023-10-02T12:00:00Z"
               }
             }
            ]
          }
        ]
      }

    NoSuchMetadataObjectException:
      value: {
        "code": 1003,
        "type": "NoSuchMetadataObjectException",
        "message": "Metadata object does not exist",
        "stack": [
          "org.apache.gravitino.exceptions.NoSuchMetadataObjectException: Metadata object does not exist",
          "..."
        ]
      }

    IllegalStatisticNameException:
      value: {
        "code": 1001,
        "type": "IllegalStatisticNameException",
        "message": "Custom statistic name must start with 'custom-'",
        "stack": [
          "org.apache.gravitino.exceptions.IllegalStatisticNameException: Custom statistic name must start with 'custom-'",
          "..."
        ]
      }

    UnmodifiableStatisticException:
      value: {
        "code": 1006,
        "type": "UnmodifiableStatisticException",
        "message": "Statistic is unmodifiable",
        "stack": [
          "org.apache.gravitino.exceptions.UnmodifiableStatisticException: Statistic is unmodifiable",
          "..."
        ]
      }