{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/peaka/main/json-schema/peaka-query-execute-request-schema.json",
  "title": "QueryExecuteRequest",
  "description": "Executes a query using the query builder. The <code>from</code> field is required.\n\n <p>Minimal example:\n <pre>\n {\n     \"from\": [\n         {\n             \"catalogName\": \"peaka\",\n             \"schemaName\": \"query\",\n             \"tableName\": \"samplequery\"\n         }\n     ]\n }\n </pre>\n\n <p>With columns, filters, limit, offset, and orderBy:\n <pre>\n {\n     \"columns\": [\"amount\"],\n     \"from\": [\n         {\n             \"catalogName\": \"wilderman_green\",\n             \"schemaName\": \"payment\",\n             \"tableName\": \"charges\"\n         }\n     ],\n     \"filters\": {\n         \"and\": [\n             [\n                 { \"column\": { \"catalogName\": \"wilderman_green\", \"schemaName\": \"payment\", \"tableName\": \"charges\", \"columnName\": \"amount\" } },\n                 \">\",\n                 [150]\n             ]\n         ]\n     },\n     \"limit\": 50,\n     \"offset\": 0,\n     \"orderBy\": [\"amount DESC\"]\n }\n </pre>",
  "x-generated": "2026-10-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/peaka-api-openapi.json#/components/schemas/QueryExecuteRequest",
  "type": "object",
  "properties": {
    "columns": {
      "type": "array",
      "description": "Columns to select. If omitted, all columns (<code>*</code>) are returned.",
      "items": {
        "type": "string"
      }
    },
    "from": {
      "type": "array",
      "description": "Tables to query from. At least one entry is required.",
      "items": {
        "$ref": "#/$defs/TableForQuery"
      }
    },
    "limit": {
      "type": "integer",
      "description": "Maximum number of rows to return.",
      "format": "int64"
    },
    "offset": {
      "type": "integer",
      "description": "Number of rows to skip before returning results.",
      "format": "int64"
    },
    "orderBy": {
      "type": "array",
      "description": "Ordering specifications. Each entry is a column name optionally followed by <code>ASC</code> or <code>DESC</code>.\n Example: <code>[&quot;amount DESC&quot;, &quot;created_at ASC&quot;]</code>.",
      "items": {
        "type": "string"
      }
    },
    "filters": {
      "type": "object",
      "additionalProperties": true,
      "description": "Filter conditions. Supports <code>and</code>/<code>or</code> logic with column comparisons."
    },
    "timeout": {
      "type": "integer",
      "description": "Query timeout in seconds. A query that runs longer is stopped and the request fails with error code 102.\n Omitted or 0: no limit. Negative values are rejected.",
      "format": "int32"
    }
  },
  "$defs": {
    "TableForQuery": {
      "type": "object",
      "properties": {
        "catalogId": {
          "type": "string"
        },
        "catalogName": {
          "type": "string"
        },
        "schemaName": {
          "type": "string"
        },
        "tableName": {
          "type": "string"
        }
      }
    }
  }
}