# Update

Launch stage: GA

`PATCH /api/2.0/sql/queries/{id}`

Updates a query.

API scopes: sql

## Path parameters

- `id` (string, optional)

## Request body

- `query` (object, optional)
  - `id` (string, optional)
    UUID identifying the query.
    Example: `fe25e731-92f2-4838-9fb2-1ca364320a3d`
  - `display_name` (string, optional)
    Display name of the query that appears in list views, widget headings, and on the query page.
    Example: `Example query`
  - `description` (string, optional)
    General description that conveys additional information about this query such as usage notes.
    Example: `Example description`
  - `owner_user_name` (string, optional)
    Username of the user that owns the query.
    Example: `user@acme.com`
  - `warehouse_id` (string, optional)
    ID of the SQL warehouse attached to the query.
    Example: `a7066a8ef796be84`
  - `query_text` (string, optional)
    Text of the query to be run.
    Example: `SELECT 1`
  - `run_as_mode` (string, optional)
    Sets the "Run as" role for the object.
    Possible values: `OWNER`, `VIEWER`
  - `lifecycle_state` (string, optional)
    Indicates whether the query is trashed.
    Possible values: `ACTIVE`, `TRASHED`
  - `last_modifier_user_name` (string, optional)
    Username of the user who last saved changes to this query.
    Example: `user@acme.com`
  - `parent_path` (string, optional)
    Workspace path of the workspace folder containing the object.
    Example: `/Users/user@acme.com`
  - `tags` (array of string, optional)
  - `create_time` (string, optional)
    Timestamp when this query was created.
  - `update_time` (string, optional)
    Timestamp when this query was last updated.
  - `parameters` (array of object, optional)
    List of query parameter definitions.
    - `title` (string, optional)
      Text displayed in the user-facing parameter widget in the UI.
    - `name` (string, optional)
      Literal parameter marker that appears between double curly braces in the query text.
    - `text_value` (object, required)
      Text query parameter value.
      - `value` (string, optional)
    - `numeric_value` (object, required)
      Numeric query parameter value.
      - `value` (double, optional)
    - `enum_value` (object, required)
      Dropdown query parameter value.
      - `values` (array of string, optional)
        List of selected query parameter values.
      - `enum_options` (string, optional)
        List of valid query parameter values, newline delimited.
      - `multi_values_options` (object, optional)
        If specified, allows multiple values to be selected for this parameter.
    - `date_value` (object, required)
      Date query parameter value. Can only specify one of `dynamic_date_value` or `date_value`.
      - `dynamic_date_value` (string, required)
        Dynamic date-time value based on current date-time.
        Possible values: `NOW`, `YESTERDAY`
      - `date_value` (string, required)
        Manually specified date-time value.
      - `precision` (string, optional)
        Date-time precision to format the value into when the query is run. Defaults to DAY_PRECISION (YYYY-MM-DD).
        Possible values: `DAY_PRECISION`, `MINUTE_PRECISION`, `SECOND_PRECISION`
    - `date_range_value` (object, required)
      Date-range query parameter value. Can only specify one of `dynamic_date_range_value` or `date_range_value`.
      - `dynamic_date_range_value` (string, required)
        Dynamic date-time range value based on current date-time.
        Possible values: `TODAY`, `YESTERDAY`, `THIS_WEEK`, `THIS_MONTH`, `THIS_YEAR`, `LAST_WEEK`, `LAST_MONTH`, `LAST_YEAR`, `LAST_HOUR`, `LAST_8_HOURS`, `LAST_24_HOURS`, `LAST_7_DAYS`, `LAST_14_DAYS`, `LAST_30_DAYS`, `LAST_60_DAYS`, `LAST_90_DAYS`, `LAST_12_MONTHS`
      - `date_range_value` (object, required)
        Manually specified date-time range value.
      - `precision` (string, optional)
        Date-time precision to format the value into when the query is run. Defaults to DAY_PRECISION (YYYY-MM-DD).
        Possible values: `DAY_PRECISION`, `MINUTE_PRECISION`, `SECOND_PRECISION`
      - `start_day_of_week` (int32, optional)
    - `query_backed_value` (object, required)
      Query-based dropdown query parameter value.
      - `values` (array of string, optional)
        List of selected query parameter values.
      - `query_id` (string, optional)
        UUID of the query that provides the parameter values.
      - `multi_values_options` (object, optional)
        If specified, allows multiple values to be selected for this parameter.
  - `apply_auto_limit` (boolean, optional)
    Whether to apply a 1000 row limit to the query result.
  - `catalog` (string, optional)
    Name of the catalog where this query will be executed.
  - `schema` (string, optional)
    Name of the schema where this query will be executed.
- `update_mask` (string, optional)
- `auto_resolve_display_name` (boolean, optional)
  If true, automatically resolve alert display name conflicts. Otherwise, fail the request if the alert's display name conflicts with an existing alert's display name.
  Default: `true`

## Returns

Returns the Query object.

## Request

```json
{
  "id": "fe25e731-92f2-4838-9fb2-1ca364320a3d",
  "query": {
    "description": "Example description updated",
    "display_name": "Example query updated",
    "query_text": "SELECT 2"
  },
  "update_mask": "display_name,description,query_text"
}
```

## Response

```json
{
  "create_time": "2019-08-24T14:15:22Z",
  "description": "Example description updated",
  "display_name": "Example query updated",
  "id": "fe25e731-92f2-4838-9fb2-1ca364320a3d",
  "last_modifier_user_name": "user@acme.com",
  "lifecycle_state": "ACTIVE",
  "owner_user_name": "user@acme.com",
  "parameters": [
    {
      "name": "foo",
      "text_value": {
        "value": "bar"
      },
      "title": "foo"
    }
  ],
  "parent_path": "/Workspace/Users/user@acme.com",
  "query_text": "SELECT 2",
  "run_as_mode": "OWNER",
  "tags": [
    "Tag 1"
  ],
  "update_time": "2019-08-24T14:15:22Z",
  "warehouse_id": "a7066a8ef796be84"
}
```

