{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "QueryDataToolRequestArguments",
    "type": "object",
    "properties": {
        "layerOrTableUrl": {
            "type": "string",
            "description": "The URL for the layer or table to be queried. This is required. Invoke describe_layer on the target layer before using 'query_data'.",
            "examples": [
                "https://arcgis-enterprise.net/server/rest/services/Hosted/EV_Charging_Stations/FeatureServer",
                "https://services1.arcgis.com/Ua5sjt3LWTPigjyD/arcgis/rest/services/Public_School_Locations_Current/MapServer"
            ]
        },
        "where": {
            "type": "string",
            "description": "An optional SQL 'where' clause to filter the results via an attribute. The WHERE clause should use valid SQL syntax and reference inspected layer fields."
        },
        "geometry": {
            "description": "An optional geometry JSON string to filter the results spatially. Should be as simple as possible and derived from another tool call that inspects the layer, or from the current conversation context. The spatial reference must be included in the geometry JSON. Example multipoint schema:\n{\"hasM\":<true|false>,\"hasZ\":<true|false>,\"points\":[[<x1>,<y1>,<z1>,<m1>],[<x2>,<y2>,<z2>,<m2>],...,[<xn>,<yn>,<zn>,<mn>]],\"ids\":[[<id1>,<id2>,...,<idn>]],\"spatialReference\":{<spatialReference>}}\nExample polygon schema:\n{\"hasZ\":<true|false>,\"hasM\":<true|false>,\"rings\":[[[<x11>,<y11>,<z11>,<m11>],...,[<x1N>,<y1N>,<z1N>,<m1N>]],...,[[<xk1>,<yk1>,<zk1>,<mk1>],...,[<xkM>,<ykM>,<zkM>,<mkM>]]],\"ids\":[[<id11>,...,<id1N>],...,[<idk1>,...,<idkM>]],\"spatialReference\":{<spatialReference>}}",
            "type": "string"
        },
        "geometryType": {
            "type": "string",
            "description": "An optional geometry type. MUST be provided if a geometry string is supplied. Use a value defined by the schema.",
            "enum": [
                "esriGeometryPoint",
                "esriGeometryMultipoint",
                "esriGeometryPolyline",
                "esriGeometryPolygon",
                "esriGeometryEnvelope"
            ],
            "default": "esriGeometryEnvelope"
        },
        "spatialRelationship": {
            "type": "string",
            "description": "An optional geospatial relationship type if a geometry string is provided. Defaults to 'esriSpatialRelIntersects'.",
            "enum": [
                "esriSpatialRelIntersects",
                "esriSpatialRelContains",
                "esriSpatialRelEnvelopeIntersects",
                "esriSpatialRelIndexIntersects",
                "esriSpatialRelWithin",
                "esriSpatialRelCrosses",
                "esriSpatialRelOverlaps",
                "esriSpatialRelTouches"
            ],
            "default": "esriSpatialRelIntersects"
        },
        "bufferDistance": {
            "type": "number",
            "description": "An optional buffer distance to use with a supplied geometry string.",
            "minimum": 0
        },
        "bufferUnits": {
            "type": "string",
            "description": "A distance buffer units value that MUST be provided if a buffer distance is specified.",
            "enum": [
                "esriSRUnit_Foot",
                "esriSRUnit_Meter",
                "esriSRUnit_Kilometer",
                "esriSRUnit_StatuteMile",
                "esriSRUnit_NauticalMile",
                "esriSRUnit_USNauticalMile"
            ]
        },
        "statistics": {
            "type": "array",
            "description": "An optional list of statistical aggregations. Each entry should specify a statistic type, a field to perform the statistic on, and an output field name. For each, the outstatistics name will be automatically generated from the type and field.",
            "items": {
                "type": "object",
                "properties": {
                    "statisticType": {
                        "type": "string",
                        "description": "The type of statistic to compute.",
                        "enum": [
                            "count",
                            "min",
                            "max",
                            "avg",
                            "sum",
                            "stddev",
                            "var"
                        ]
                    },
                    "onField": {
                        "type": "string",
                        "description": "The field to perform the statistic on. Should be a field from the inspected layer."
                    }
                },
                "required": [
                    "statisticType",
                    "onField"
                ]
            }
        },
        "groupByField": {
            "type": "string",
            "description": "A field to group the statistics results by. Only use if statistics are provided. Should be a field from the inspected layer."
        },
        "orderByFields": {
            "type": "array",
            "description": "An optional list of fields to sort the results by. Each entry specifies a field name and sort order. IF STATISTICS ARE REQUESTED IT COULD ALSO REFER TO A STATISTIC NAME RATHER THAN A RAW FIELD NAME!",
            "items": {
                "type": "object",
                "properties": {
                    "fieldName": {
                        "type": "string",
                        "description": "The field name to sort on. Should be from the inspected layer fields or a statistic output field."
                    },
                    "order": {
                        "type": "string",
                        "description": "Sort order: 'ASC' for ascending or 'DESC' for descending.",
                        "enum": [
                            "ASC",
                            "DESC"
                        ],
                        "default": "ASC"
                    }
                },
                "required": [
                    "fieldName"
                ]
            }
        },
        "pageSize": {
            "type": "integer",
            "description": "The number of records to return for a query that does not involve aggregations or statistics",
            "default": 100,
            "minimum": 1,
            "maximum": 1000
        },
        "resultOffset": {
            "type": "integer",
            "description": "The number of records to skip when returning multiple pages of data",
            "default": 0,
            "minimum": 0
        },
        "returnGeometry": {
            "type": "boolean",
            "description": "Whether to return the geometry for each matching record",
            "default": false
        }
    },
    "dependentRequired": {
        "geometry": [
            "geometryType"
        ],
        "bufferDistance": [
            "bufferUnits"
        ],
        "groupByField": [
            "statistics"
        ]
    },
    "required": [
        "layerOrTableUrl"
    ]
}