[Apache Pig](https://pig.apache.org/) lets you analyze large datasets on Managed Service for Apache Spark. You can install this open source platform during cluster creation by using the [Optional components](https://docs.cloud.google.com/managed-spark/docs/concepts/components/overview.md.txt#available_optional_components) feature.

## Install the component

Install the component when you create a Managed Service for Apache Spark cluster.

Apache Pig is an optional component in Managed Service for Apache Spark `2.3` and later
image versions.

> [!NOTE]
> **Note:** Apache Pig is automatically installed on Managed Service for Apache Spark `2.2` and earlier image versions.

See
[Supported Managed Service for Apache Spark versions](https://docs.cloud.google.com/managed-spark/docs/concepts/versioning/dataproc-versions#supported_cloud_dataproc_versions)
for component versions included in the latest Managed Service for Apache Spark image
releases.

### Google Cloud console

1. In the Google Cloud console, open the [**Create cluster**](https://console.cloud.google.com/dataproc/clusters/create) page.
2. Click **Additional configuration** to expand that section.
3. Edit **Optional components**.
4. In the panel that opens, select the checkbox for **Pig** , then click **Save**.

### gcloud CLI

To create a Managed Service for Apache Spark cluster that includes the Pig component,
use the
[`gcloud dataproc clusters create CLUSTER_NAME`](https://docs.cloud.google.com/sdk/gcloud/reference/dataproc/clusters/create.md.txt)
command with the `--optional-components` flag (using image version
2.3 or later).

```
gcloud dataproc clusters create CLUSTER_NAME \
    --region=REGION \
    --optional-components=PIG \
    --image-version=2.3 \
    ... other flags
```

### REST API

The Pig component can be specified through the Dataproc API
using
[SoftwareConfig.Component](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/ClusterConfig.md.txt#Component)
as part of a
[clusters.create](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/projects.regions.clusters/create.md.txt)
request.