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

# Spark

> Execute a SQL query against the oleander lake using managed Spark. The query runs as a named job in the specified namespace. Results are written to `output_table` as an Iceberg table. Lineage is captured automatically for every run.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v2/spark/query
openapi: 3.0.1
info:
  title: Oleander API
  description: >-
    Oleander implements the api spec as defined by OpenLineage to ingest data.
    We also provide a RESTful API to extract data within our system.
  version: 1.0.0
servers:
  - url: https://oleander.dev
security:
  - bearerAuth: []
paths:
  /api/v2/spark/query:
    post:
      summary: Spark
      description: >-
        Execute a SQL query against the oleander lake using managed Spark. The
        query runs as a named job in the specified namespace. Results are
        written to `output_table` as an Iceberg table. Lineage is captured
        automatically for every run.
      operationId: sparkQuery
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - namespace
                - name
                - query
                - output_table
              properties:
                namespace:
                  type: string
                  description: >-
                    Job namespace used to identify this query in lineage and run
                    history.
                  example: oleander.query
                name:
                  type: string
                  description: >-
                    Job name. Combined with `namespace` to form the unique job
                    identity.
                  example: flowers_copy
                query:
                  type: string
                  description: >-
                    SQL query to execute. Supports all Spark SQL syntax and can
                    reference any table in your Iceberg catalogs.
                  example: SELECT * FROM oleander.default.flowers
                output_table:
                  type: string
                  description: >-
                    Destination Iceberg table for query results. Format:
                    `catalog.namespace.table`. The table is created if it does
                    not exist.
                  example: oleander.default.flowers_query_spark_sql
                driver_machine_type:
                  type: string
                  description: Machine type for the Spark driver.
                  example: spark.1.b
                  default: spark.1.b
                executor_machine_type:
                  type: string
                  description: Machine type for each Spark executor.
                  example: spark.1.b
                  default: spark.1.b
                executor_numbers:
                  type: integer
                  description: Number of Spark executors to allocate.
                  example: 1
                  default: 1
      responses:
        '200':
          description: Query submitted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  run_id:
                    type: string
                    format: uuid
                    description: >-
                      Run ID for this Spark query execution. Use this to track
                      the run in the oleander platform.
                  job:
                    type: object
                    properties:
                      namespace:
                        type: string
                      name:
                        type: string
                  output_table:
                    type: string
                    description: The destination table results will be written to.
                  status:
                    type: string
                    description: Initial run status.
                    example: RUNNING
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          description: Unauthorized - missing or invalid Bearer token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unauthorized
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      required:
        - status
      type: object
      properties:
        status:
          type: integer
          format: int32
          default: 500
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````