> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# IPreparedExecution

- Package: [@gooddata/sdk-backend-spi](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/index.md)
- Kind: interface
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-backend-spi/src/workspace/execution/index.ts

Prepared execution already knows what data to calculate and allows to specify how the data should be sorted and shaped into dimensions.

**Signature:**

```typescript
export interface IPreparedExecution extends ICancelable<IPreparedExecution> 
```
**Extends:** [ICancelable](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.icancelable/index.md)&lt;[IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)&gt;

## Remarks

To this end, it provides several functions to customize sort items and dimensions. The prepared execution is immutable and so all the customization functions WILL result in a new instance of prepared execution.

The contract for creating these new instances is that the new prepared execution MUST be created using the execution factory that created current execution.

Note that even though the prepared executions are immutable, the abort signal itself is stateful and is always propagated through the whole immutable chain. If you don't want to cancel multiple executions simultaneously via single abort signal, you need to set it on the outermost execution only, just before calling the execute method.

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [context?](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutioncontext) | `readonly` | [IExecutionContext](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iexecutioncontext/index.md) | _(Optional)_ Arbitrary execution metadata provided by the caller. |
| [definition](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutiondefinition) | `readonly` | [IExecutionDefinition](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.iexecutiondefinition/index.md) | Definition of the execution accumulated to so far. |
| [signal?](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionsignal) | `readonly` | AbortSignal | _(Optional)_ Abort signal to cancel the execution or its result. |

## Methods

| Method | Description |
| --- | --- |
| [equals(other)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionequals) | Tests whether this execution and the other execution are the same. |
| [execute()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionexecute) | Starts the execution. |
| [fingerprint()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionfingerprint) | Fingerprint of this prepared execution. |
| [withContext(context)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionwithcontext) | Attaches custom execution context metadata. |
| [withDateFormat(dateFormat)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionwithdateformat) | Adds the desired date format to the postProcessing of an IPreparedExecution. |
| [withDimensions(dim)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionwithdimensions) | Configures dimensions of the resulting data. Any dimension settings accumulated so far WILL be wiped out. |
| [withExecConfig(config)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionwithexecconfig) | Additional execution configuration |
| [withSorting(items)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md#ipreparedexecutionwithsorting) | Changes sorting of the resulting data. Any sorting settings accumulated so far WILL be wiped out. |

## Property details

### IPreparedExecution.context

Arbitrary execution metadata provided by the caller.

**Signature:**

```typescript
readonly context?: IExecutionContext;
```

### IPreparedExecution.definition

Definition of the execution accumulated to so far.

**Signature:**

```typescript
readonly definition: IExecutionDefinition;
```

### IPreparedExecution.signal

Abort signal to cancel the execution or its result.

**Signature:**

```typescript
readonly signal?: AbortSignal;
```

## Method details

### IPreparedExecution.equals()

Tests whether this execution and the other execution are the same.

**Signature:**

```typescript
equals(other: IPreparedExecution): boolean;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| other | [IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md) | another execution |

**Returns:**

boolean

#### Remarks

This effectively means that their definitions are deeply equal.

If you are only concerned with the equality from the result calculation point of view, consider comparing fingerprints instead.

### IPreparedExecution.execute()

Starts the execution.

**Signature:**

```typescript
execute(): Promise<IExecutionResult>;
```
**Returns:**

Promise&lt;[IExecutionResult](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iexecutionresult/index.md)&gt;

### IPreparedExecution.fingerprint()

Fingerprint of this prepared execution.

**Signature:**

```typescript
fingerprint(): string;
```
**Returns:**

string

#### Remarks

This is effectively the fingerprint of the execution definition underlying this instance of Prepared Execution.

### IPreparedExecution.withContext()

Attaches custom execution context metadata.

**Signature:**

```typescript
withContext(context: IExecutionContext): IPreparedExecution;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| context | [IExecutionContext](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.iexecutioncontext/index.md) | metadata to associate with this execution |

**Returns:**

[IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)

new execution containing the provided context

### IPreparedExecution.withDateFormat()

Adds the desired date format to the postProcessing of an IPreparedExecution.

**Signature:**

```typescript
withDateFormat(dateFormat: string): IPreparedExecution;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dateFormat | string | Format to be applied to the dates in an AFM execution response. |

**Returns:**

[IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)

new execution with the updated postProcessing

### IPreparedExecution.withDimensions()

Configures dimensions of the resulting data. Any dimension settings accumulated so far WILL be wiped out.

**Signature:**

```typescript
withDimensions(...dim: Array<IDimension | DimensionGenerator>): IPreparedExecution;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dim | Array&lt;[IDimension](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idimension/index.md) \| [DimensionGenerator](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dimensiongenerator/index.md)&gt; | dimensions to set |

**Returns:**

[IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)

new execution with the updated dimensions

#### Remarks

The realizations of analytical backend MAY impose constraints on the minimum and maximum number of dimensions. This call WILL fail if the input dimensions do not match constraints imposed by the backend.

### IPreparedExecution.withExecConfig()

Additional execution configuration

**Signature:**

```typescript
withExecConfig(config: IExecutionConfig): IPreparedExecution;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| config | [IExecutionConfig](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.iexecutionconfig/index.md) |  |

**Returns:**

[IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)

### IPreparedExecution.withSorting()

Changes sorting of the resulting data. Any sorting settings accumulated so far WILL be wiped out.

**Signature:**

```typescript
withSorting(...items: ISortItem[]): IPreparedExecution;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| items | [ISortItem](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.isortitem/index.md)[] | items to sort by |

**Returns:**

[IPreparedExecution](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)

new execution with the updated sorts
