{
  "$id": "https://opendatafabric.org/schemas/datasets/v1alpha1/Transform",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Engine-specific processing queries that shape the resulting data.",
  "$defs": {
    "Sql": {
      "description": "Transform using one of the SQL dialects.",
      "type": "object",
      "required": [
        "engine"
      ],
      "properties": {
        "engine": {
          "type": "string",
          "description": "Identifier of the engine used for this transformation."
        },
        "version": {
          "type": "string",
          "description": "Version of the engine to use."
        },
        "query": {
          "type": "string",
          "description": "SQL query the result of which will be used as an output. This is a convenience property meant only for defining queries by hand. When stored in the metadata this property will never be set and instead will be converted into a single-iter `queries` array."
        },
        "queries": {
          "type": "array",
          "description": "Specifies multi-step SQL transformations. Each step acts as a shorthand for `CREATE TEMPORARY VIEW <alias> AS (<query>)`. Last query in the array should have no alias and will be treated as an output.",
          "items": {
            "$ref": "https://opendatafabric.org/schemas/datasets/v1alpha1/SqlQueryStep",
            "unevaluatedProperties": false
          }
        },
        "temporalTables": {
          "type": "array",
          "description": "Temporary Flink-specific extension for creating temporal tables from streams.",
          "items": {
            "$ref": "https://opendatafabric.org/schemas/datasets/v1alpha1/TemporalTable",
            "unevaluatedProperties": false
          }
        }
      }
    }
  },
  "oneOf": [
    {
      "allOf": [
        {
          "properties": {
            "kind": {
              "type": "string",
              "const": "Sql"
            }
          },
          "required": [
            "kind"
          ]
        },
        {
          "$ref": "#/$defs/Sql"
        }
      ]
    }
  ]
}
