# REST Resource: customers.analysisQueries

- [Resource: AnalysisQuery](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#AnalysisQuery)
  - [JSON representation](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#AnalysisQuery.SCHEMA_REPRESENTATION)
- [MergeSpec](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeSpec)
  - [JSON representation](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeSpec.SCHEMA_REPRESENTATION)
- [MergeColumn](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeColumn)
  - [JSON representation](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeColumn.SCHEMA_REPRESENTATION)
- [MergeType](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeType)
- [FilteredRowSummary](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#FilteredRowSummary)
  - [JSON representation](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#FilteredRowSummary.SCHEMA_REPRESENTATION)
- [ColumnSummaryRule](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#ColumnSummaryRule)
  - [JSON representation](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#ColumnSummaryRule.SCHEMA_REPRESENTATION)
- [SummaryType](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#SummaryType)
- [Methods](https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#METHODS_SUMMARY)

## Resource: AnalysisQuery

Defines an analysis query that can be executed within Ads Data Hub.

| JSON representation |
|---|
| ``` { "name": string, "title": string, "queryText": string, "parameterTypes": { string: { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/ParameterType`) }, ... }, "mergeSpec": { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeSpec`) }, "queryState": enum (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/QueryState`), "updateTime": string, "updateEmail": string, "createTime": string, "createEmail": string, "queryShare": [ { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/QueryShare`) } ], // Union field `filtered_row` can be only one of the following: "filteredRowSummary": { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#FilteredRowSummary`) }, "generateFilteredRowSummaryAutomatically": boolean // End of list of possible types for union field `filtered_row`. } ``` |

| Fields ||
|---|---|
| `name` | `string` Output only. Immutable. Name that uniquely identifies a query. It has the form customers/\[customerId\]/analysisQueries/\[resource_id\], e.g. 'customers/123/analysisQueries/abcd1234'. The resource ID is generated by the server. |
| `title` | `string` Query title, which is unique within a single Ads Data Hub customer and query type. |
| `queryText` | `string` Query text written in Standard SQL. See <https://cloud.google.com/bigquery/docs/reference/standard-sql/>. |
| `parameterTypes` | ``map (key: string, value: object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/ParameterType`))`` Any additional parameters expected by the query. Maps each argument name to its argument type. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `mergeSpec (deprecated)` | ``object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeSpec`)`` > [!WARNING] > Use filtered_row_summary. Instructions for row merging. If present, then any rows that would have been dropped for privacy reasons will be combined into a single merged row. The merged row will be in the final output if the merged row meets privacy requirements. |
| `queryState` | ``enum (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/QueryState`)`` Query state. |
| `updateTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` Output only. Time the query was last updated. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `updateEmail` | `string` Output only. Email address of user who last updated the query. |
| `createTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` Output only. Immutable. Time the query was created. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `createEmail` | `string` Output only. Immutable. Email address of user who created the query. |
| `queryShare[]` | ``object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/QueryShare`)`` Indicates ways that a query may be shared beyond the owning Ads Data Hub customer. |
| Union field `filtered_row`. Instructions for row merging. `filtered_row` can be only one of the following: ||
| `filteredRowSummary` | ``object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#FilteredRowSummary`)`` Define how to combine rows dropped for privacy reasons into a single merged row. The merged row will be included in the final output if the merged row meets privacy requirements. |
| `generateFilteredRowSummaryAutomatically` | `boolean` If true, a filtered row summary is generated automatically. |

## MergeSpec

> [!WARNING]
> We no longer use MergeSpec. Use FilteredRowSummary.

Merge instructions for an analysis query result schema.

| JSON representation |
|---|
| ``` { "columns": { string: { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeColumn`) }, ... } } ``` |

| Fields ||
|---|---|
| `columns` | ``map (key: string, value: object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeColumn`))`` Instructions for merging each column, keyed by name. Any missing columns will be treated as MERGE_TYPE_UNSPECIFIED. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |

## MergeColumn

> [!WARNING]
> We no longer use MergeColumn in MergeSpec. Use ColumnSummaryRule in FilteredRowSummary instead.

Merge instructions for a single output column.

| JSON representation |
|---|
| ``` { "type": enum (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeType`), "value": { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/ParameterValue`) } } ``` |

| Fields ||
|---|---|
| `type` | ``enum (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#MergeType`)`` Method used to combine the values for the column. |
| `value` | ``object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/ParameterValue`)`` The constant value to use (only valid for CONSTANT merge type). |

## MergeType

All supported operations for column merging.

| Enums ||
|---|---|
| `MERGE_TYPE_UNSPECIFIED` | Unspecified merge type. The merged column value will be NULL. |
| `CONSTANT` | Replace merged column value with the given constant. |
| `SUM` | Take the sum of the merged column values. |

## FilteredRowSummary

Merge instructions for an analysis query result schema.

| JSON representation |
|---|
| ``` { "columns": { string: { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#ColumnSummaryRule`) }, ... } } ``` |

| Fields ||
|---|---|
| `columns` | ``map (key: string, value: object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#ColumnSummaryRule`))`` Instructions for merging each column, keyed by name. Any missing columns will be treated as SUMMARY_TYPE_UNSPECIFIED. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |

## ColumnSummaryRule

Merge instructions for a single output column.

| JSON representation |
|---|
| ``` { "type": enum (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#SummaryType`), "value": { object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/ParameterValue`) } } ``` |

| Fields ||
|---|---|
| `type` | ``enum (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries#SummaryType`)`` Method used to combine the values for the column. |
| `value` | ``object (`https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/ParameterValue`)`` The constant value to use (only valid for CONSTANT summary type). |

## SummaryType

All supported operations for column merging.

| Enums ||
|---|---|
| `SUMMARY_TYPE_UNSPECIFIED` | Unspecified summary type. The summary column value will be NULL. |
| `CONSTANT` | Replace merged column value with the given constant. |
| `SUM` | Take the sum of the merged column values. |

| ## Methods ||
|---|---|
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/create` | Creates an analysis query for later execution. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/delete` | Deletes an analysis query. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/get` | Retrieves the requested analysis query. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/list` | Lists the analysis queries owned by the specified customer. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/patch` | Updates an existing analysis query. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/start` | Starts execution on a stored analysis query. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/startTransient` | Starts execution on a transient analysis query. |
| ### `https://developers.google.com/ads-data-hub/marketers/reference/rest/v1/customers.analysisQueries/validate` | Performs static validation checks on the provided analysis query. |