{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gmr.github.io/pglifecycle/schemata/operators.json",
  "title": "Operators",
  "description": "Specifies all user-defined operators in a schema",
  "type": "object",
  "properties": {
    "schema": {
      "title": "Schema",
      "description": "The schema every object in this file belongs to.",
      "type": "string"
    },
    "owner": {
      "title": "Owner",
      "description": "The role that owns every object in this file, unless an entry names its own. Defaults to the project's superuser.\n",
      "type": "string"
    },
    "operators": {
      "title": "User-defined operators",
      "type": "array",
      "items": {
        "title": "Operator",
        "description": "User defined comparison operator",
        "type": "object",
        "properties": {
          "name": {
            "title": "Name",
            "description": "The name of the operator function to create.",
            "type": "string"
          },
          "schema": {
            "title": "Schema",
            "description": "The schema to create the operator function in.",
            "type": "string"
          },
          "owner": {
            "title": "Owner",
            "description": "The role that owns the operator function.",
            "type": "string"
          },
          "sql": {
            "title": "SQL Statement",
            "description": "User-provided raw SQL snippet",
            "type": "string"
          },
          "function": {
            "title": "Function or Procedure Name",
            "description": "The function used to implement this operator.",
            "type": "string"
          },
          "left_arg": {
            "title": "Left Operand",
            "description": "The data type of the operator's left operand, if any. This option would be omitted for a left-unary operator.\n",
            "type": "string"
          },
          "right_arg": {
            "title": "Right Operand",
            "description": "The data type of the operator's right operand, if any. This option would be omitted for a right-unary operator.\n",
            "type": "string"
          },
          "commutator": {
            "title": "Commutator",
            "description": "The commutator of this operator.",
            "type": "string"
          },
          "negator": {
            "title": "Negator",
            "description": "The negator of this operator.",
            "type": "string"
          },
          "restrict": {
            "title": "Restriction Selectivity Estimator Function",
            "description": "The restriction selectivity estimator function for this operator.",
            "type": "string"
          },
          "join": {
            "title": "Join Selectivity Estimator Function",
            "description": "The join selectivity estimator function for this operator.",
            "type": "string"
          },
          "hashes": {
            "title": "Hashes",
            "description": "Indicates this operator can support a hash join.",
            "type": "boolean"
          },
          "merges": {
            "title": "Merges",
            "description": "Indicates this operator can support a merge join.",
            "type": "boolean"
          },
          "comment": {
            "title": "Comment",
            "description": "An optional comment about the operator.",
            "type": "string"
          },
          "dependencies": {
            "title": "Dependencies",
            "description": "Objects this object depends on, for the cases the dependency graph cannot infer: an ordering the topological sort would otherwise get wrong, such as a foreign key between tables or an inheritance parent.\nEach entry names an object as `schema.name`, or unqualified for a schemaless type. A function or aggregate carries its argument signature (`test.f(integer)`) and a cast its types (`(int4 AS timestamp)`), since the name alone is ambiguous.\n",
            "type": "object",
            "properties": {
              "aggregates": {
                "description": "The aggregates this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "collations": {
                "description": "The collations this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "domains": {
                "description": "The domains this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "event_triggers": {
                "description": "The event triggers this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "extensions": {
                "description": "The extensions this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "foreign_data_wrappers": {
                "description": "The foreign data wrappers this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "functions": {
                "description": "The functions this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "languages": {
                "description": "The languages this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "materialized_views": {
                "description": "The materialized views this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "publications": {
                "description": "The publications this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "sequences": {
                "description": "The sequences this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "servers": {
                "description": "The servers this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "subscriptions": {
                "description": "The subscriptions this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "tables": {
                "description": "The tables this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "types": {
                "description": "The types this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "user_mappings": {
                "description": "The user mappings this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "users": {
                "description": "The users this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "views": {
                "description": "The views this object depends on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": false
          }
        },
        "oneOf": [
          {
            "required": [
              "sql"
            ],
            "not": {
              "required": [
                "function",
                "left_arg",
                "right_arg",
                "commutator",
                "negator",
                "restrict",
                "join",
                "hashes",
                "merges",
                "sql"
              ]
            }
          },
          {
            "required": [
              "function"
            ],
            "not": {
              "required": [
                "sql"
              ]
            }
          }
        ]
      }
    }
  },
  "required": [
    "schema",
    "operators"
  ],
  "additionalProperties": false
}