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

# Get a generated query

> Get a data engineering query: the SQL as stored, the Trino SQL to edit
and preview, and the scheduled jobs that run it. Only its owner can read it.



## OpenAPI

````yaml get /api/dataeng/query/{query_id}
openapi: 3.1.0
info:
  title: Nx1 AI API
  description: |

    AI API for Nx1 Data Platform Management and Automated Data Tasks.

    Authentication is required via PSK in Authorization header.

    Default PSK is | [ask a friend] |
  version: 0.10.2
servers: []
security: []
paths:
  /api/dataeng/query/{query_id}:
    get:
      tags:
        - Data engineering
      summary: Get a generated query
      description: >-
        Get a data engineering query: the SQL as stored, the Trino SQL to edit

        and preview, and the scheduled jobs that run it. Only its owner can read
        it.
      operationId: get_query_api_dataeng_query__query_id__get
      parameters:
        - name: query_id
          in: path
          required: true
          schema:
            type: string
            title: Query Id
        - name: preview_rows
          in: query
          required: false
          schema:
            type: integer
            maximum: 50
            minimum: 0
            description: Also run it and return this many rows.
            default: 0
            title: Preview Rows
          description: Also run it and return this many rows.
      responses:
        '200':
          description: The query, and the scheduled jobs that run it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataEngQueryDetail'
        '404':
          description: Query not found, or owned by another user.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - OAuth2AuthorizationCodeBearer: []
        - APIKeyHeader: []
components:
  schemas:
    DataEngQueryDetail:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        job_name:
          type: string
          title: Job Name
        is_federated:
          type: boolean
          title: Is Federated
        owner_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Owner Id
        query:
          type: string
          title: Query
          description: The SQL as stored and as scheduled jobs run it.
        editable_sql:
          type: string
          title: Editable Sql
          description: >-
            The same query in Trino SQL — edit and preview this one. Differs
            from `query` for non-federated queries, which run on Spark.
        scheduled_jobs:
          items:
            $ref: '#/components/schemas/DataEngScheduledJob'
          type: array
          title: Scheduled Jobs
        preview:
          anyOf:
            - $ref: '#/components/schemas/DataResponse'
            - type: 'null'
          description: A few rows of its output, when asked for.
        preview_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Preview Error
          description: Why the preview could not run, if it failed.
      type: object
      required:
        - id
        - job_name
        - is_federated
        - query
        - editable_sql
      title: DataEngQueryDetail
      description: A saved data-engineering query, for reading and editing.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DataEngScheduledJob:
      properties:
        job_id:
          type: string
          format: uuid
          title: Job Id
        job_name:
          type: string
          title: Job Name
        schedule:
          anyOf:
            - type: string
            - type: 'null'
          title: Schedule
        airflow_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Airflow Url
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Why the job's DAG could not be updated, if it failed.
      type: object
      required:
        - job_id
        - job_name
      title: DataEngScheduledJob
      description: A scheduled job that runs a data-engineering query.
    DataResponse:
      properties:
        start:
          type: integer
          title: Start
          description: >-
            The starting offset for pagination when returning a subset of the
            dataset.
        row_count:
          type: integer
          title: Row Count
          description: The number of rows included in the current response.
        next_start:
          anyOf:
            - type: integer
            - type: 'null'
          title: Next Start
          description: >-
            The offset value for the next page of data, if additional results
            are available.
        columns:
          items:
            type: string
          type: array
          title: Columns
          description: >-
            A list of column names representing the structure of the returned
            dataset.
        data:
          anyOf:
            - items:
                items: {}
                type: array
              type: array
            - type: 'null'
          title: Data
          description: >-
            The actual tabular data returned, where each inner list represents a
            row of values.
      type: object
      required:
        - start
        - row_count
        - columns
      title: DataResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    OAuth2AuthorizationCodeBearer:
      type: oauth2
      flows:
        authorizationCode:
          scopes: {}
          authorizationUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/auth
          tokenUrl: >-
            https://sso-rapid.rapid.nx1cloud.com/realms/rapid/protocol/openid-connect/token
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization-PSK

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.