> ## Documentation Index
> Fetch the complete documentation index at: https://help.lobyco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query the table



## OpenAPI

````yaml openapi/delta-sharing-v0-2.yaml POST /shares/{share}/schemas/{schema}/tables/{table}/query
openapi: 3.0.2
info:
  description: |
    The Delta Sharing protocol is still very early in its development.
  version: '0.2'
  title: Delta Sharing Protocol
  license:
    name: AGPL v3.0
    url: https://www.gnu.org/licenses/agpl-3.0.en.html
servers:
  - url: http://localhost:8000/api/v1
    description: Local dev server (APIv1)
  - url: https://sharing.delta.io/delta-sharing/
    description: Demo Delta Sharing server
security: []
tags:
  - name: shares
    description: Share discovery APIs
  - name: schemas
    description: Schema discovery APIs
  - name: tables
    description: Table query and inspection APIs
  - name: official
    description: APIs which are part of published official document
  - name: proposed
    description: APIs which are part proposed and may or may not be part of official
paths:
  /shares/{share}/schemas/{schema}/tables/{table}/query:
    post:
      tags:
        - tables
        - official
      summary: Query the table
      operationId: QueryTable
      parameters:
        - in: path
          name: share
          required: true
          description: Named share for finding the named schema
          schema:
            type: string
        - in: path
          name: schema
          required: true
          description: Named schema for finding the named table
          schema:
            type: string
        - in: path
          name: table
          required: true
          description: Named table
          schema:
            type: string
        - in: query
          name: startingTimestamp
          required: false
          description: Starting Timestamp
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryRequest'
      responses:
        '200':
          description: |
            A sequence of JSON strings containing the table protocol, metadata,
            and then a number of lines for each file in the table.
          headers:
            Delta-Table-Version:
              description: A long value which represents the current table version
              schema:
                type: integer
          content:
            application/x-ndjson:
              schema:
                $ref: '#/components/schemas/TableQueryResponse'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '500':
          $ref: '#/components/responses/500'
components:
  schemas:
    QueryRequest:
      type: object
      properties:
        predicateHints:
          type: array
          description: >
            a list of SQL boolean expressions using a restricted subset of SQL,
            in a JSON array.

            When it’s present, the server will use the provided predicates as a
            hint to apply the

            SQL predicates on the returned files. Filtering files based on the
            SQL predicates

            is BEST EFFORT. The server may return files that don’t satisfy the
            predicates.

            If the server fails to parse one of the SQL predicates, or fails to
            evaluate it, the

            server may skip it. Predicate expressions are conjunctive (AND-ed
            together).

            When it’s absent, the server will return all of files in the table.

            This will be deprecated once all the client and server
            implementation move to using jsonPredicateHints below.
          example:
            - col = 123
          items:
            type: string
        jsonPredicateHints:
          type: object
          description: >
            query predicates on partition columns specified using a structured
            JSON format.

            When it’s present, the server will try to use the predicates to
            filter table's

            files, which could boost query performance.

            As with predicateHints, this filtering is BEST EFFORT. The server
            may return files

            that don’t satisfy the predicates.

            If the server encounters any errors during predicate processing (for
            example, invalid

            syntax or non existing columns), it will skip filtering and return
            all the files.

            When it’s absent, the server will return all the files in the table.
          properties:
            op:
              $ref: '#/components/schemas/Ops'
            children:
              type: string
            name:
              type: string
            value:
              type: string
            valueType:
              type: string
        limitHint:
          type: integer
          example: 1000
          description: |
            It’s a hint from the client to tell the server how many rows the
            client plans to read. The server can use this hint to return only
            some files by using the stats in the Delta transaction logs. For
            example, when running SELECT * FROM table LIMIT 1000, the client
            can send limit=1000 to the server
        version:
          type: integer
          description: |
            an optional version number. If set, will return files as of the
            specified version of the table. This is only supported on tables
            with history sharing enabled.
          example: 1005
        timestamp:
          type: string
          example: yyyy-[m]m-[d]d hh:mm:ss[.f...]
          description: >
            an optional timestamp string in the Timestamp Format,. If set, will

            return files as of the table version corresponding to the specified

            timestamp. This is only supported on tables with history sharing
            enabled.
        startingVersion:
          type: integer
          example: 1000
          description: >
            an optional version number. If set, will return all data change
            files

            since startingVersion, inclusive, including historical metadata if
            seen

            in the delta log.
        endingVersion:
          type: integer
          example: 1000
          description: >
            an optional version number, only used if startingVersion is set. If
            set,

            the server can use it as a hint to avoid returning data change files
            after

            endingVersion. This is not enforcement. Hence, when sending the
            endingVersion

            parameter, the client should still handle the case that it may
            receive files

            after endingVersion.
    TableQueryResponse:
      type: string
      example: >
        {"protocol":{"minReaderVersion":1}}

        {"metaData":{"id":"f8d5c169-3d01-4ca3-ad9e-7dc3355aedb2","format":{"provider":"parquet"},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"eventTime\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}},{\"name\":\"date\",\"type\":\"date\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":["date"]}}

        {"file":{"url":"https://<s3-bucket-name>.s3.us-west-2.amazonaws.com/delta-exchange-test/table2/date%3D2021-04-28/part-00000-8b0086f2-7b27-4935-ac5a-8ed6215a6640.c000.snappy.parquet?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210501T010516Z&X-Amz-SignedHeaders=host&X-Amz-Expires=900&X-Amz-Credential=AKIAISZRDL4Q4Q7AIONA%2F20210501%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=97b6762cfd8e4d7e94b9d707eff3faf266974f6e7030095c1d4a66350cfd892e","id":"8b0086f2-7b27-4935-ac5a-8ed6215a6640","partitionValues":{"date":"2021-04-28"},"size":573,"stats":"{\"numRecords\":1,\"minValues\":{\"eventTime\":\"2021-04-28T23:33:57.955Z\"},\"maxValues\":{\"eventTime\":\"2021-04-28T23:33:57.955Z\"},\"nullCount\":{\"eventTime\":0}}"}}

        {"file":{"url":"https://<s3-bucket-name>.s3.us-west-2.amazonaws.com/delta-exchange-test/table2/date%3D2021-04-28/part-00000-591723a8-6a27-4240-a90e-57426f4736d2.c000.snappy.parquet?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210501T010516Z&X-Amz-SignedHeaders=host&X-Amz-Expires=899&X-Amz-Credential=AKIAISZRDL4Q4Q7AIONA%2F20210501%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Signature=0f7acecba5df7652457164533a58004936586186c56425d9d53c52db574f6b62","id":"591723a8-6a27-4240-a90e-57426f4736d2","partitionValues":{"date":"2021-04-28"},"size":573,"stats":"{\"numRecords\":1,\"minValues\":{\"eventTime\":\"2021-04-28T23:33:48.719Z\"},\"maxValues\":{\"eventTime\":\"2021-04-28T23:33:48.719Z\"},\"nullCount\":{\"eventTime\":0}}"}}
    Ops:
      type: string
      enum:
        - column
        - literal
        - isNull
        - equal
        - lessThan
        - lessThanOrEqual
        - greaterThan
        - greaterThanOrEqual
        - and
        - or
        - not
      description: "Op \t                Op Type \tDescription\ncolumn \t            Leaf \tRepresents a column. A column op has two fields: name and valueType. The column's value will be cast to the specified valueType during comparisons.\nliteral \t        Leaf    Represents a literal or fixed value. A literal op has two fields: value and valueType. The literal's value will be cast to the specified valueType during comparisons.\nisNull \t            Unary \tRepresents a null check on a column op. This op should have only one child, the column op.\nequal \t            Binary \tRepresents an equality (\"=\") check. This op should have two children, and both should be leaf ops.\nlessThan \t        Binary \tRepresents a less than (\"<\") check. This op should have two children, and both should be leaf ops.\nlessThanOrEqual\t    Binary \tRepresents a less than or equal (\"<=\") check. This op should have two children, and both should be leaf ops.\ngreaterThan \t    Binary \tRepresents a greater than (\">\") check. This op should have two children, and both should be leaf ops.\ngreaterThanOrEqual \tBinary \tRepresents a greater than (\">=\") check. This op should have two children, and both should be leaf ops.\nand \t            Nary \tRepresents a logical and operation amongst its children. This op should have at least two children.\nor \t                Nary \tRepresents a logical or operation amongst its children. This op should have at least two children.\nnot \t            Unary \tRepresents a logical not check. This op should have once child.\nThe supported value types:\n  ValueType \tDescription\n  \"bool\" \tRepresents an Boolean type.\n  \"int\" \tRepresents an Integer type.\n  \"long\" \tRepresents a Long type.\n  \"string\" \tRepresents a String type.\n  \"date\" \tRepresents a Date type in \"yyyy-mm-dd\" format.\n"
    CommonErrorResponse:
      type: object
      properties:
        errorCode:
          type: string
        message:
          type: string
  responses:
    '400':
      description: The request is malformed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CommonErrorResponse'
    '401':
      description: The request is unauthenticated. The bearer token is missing or incorrect
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CommonErrorResponse'
    '403':
      description: The request is forbidden from being fulfilled
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CommonErrorResponse'
    '404':
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CommonErrorResponse'
    '500':
      description: The request is not handled correctly due to a server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CommonErrorResponse'

````