> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Script gem for Data Analysis

> Embed a custom Python script in your pipeline

export const gemName_0 = "Script"

<Tip>
  The {gemName_0} gem has a corresponding interactive gem example. See [Interactive gem
  examples](/data-analysis/gems/gems#interactive-gem-examples) to learn how to run sample pipelines
  for this and other gems.
</Tip>

## Where the script runs

The execution environment for the Script gem depends on the [SQL warehouse](/data-analysis/environment/fabrics/prophecy-fabrics) configured in your Prophecy fabric.

| SQL warehouse provider | Execution environment |
| ---------------------- | --------------------- |
| Databricks             | Databricks Serverless |
| Prophecy In Memory     | Prophecy Automate     |
| BigQuery               | Prophecy Automate     |
| Snowflake              | Prophecy Automate     |

This ensures your Python logic runs in an environment optimized for your data platform.

## Parameters

| Parameter | Description                             |
| --------- | --------------------------------------- |
| Script    | Where you will write your Python script |

<Info>
  Number of inputs and outputs can be changed as needed by clicking the `+` button on the respective
  tab.
</Info>

## Troubleshooting

### Permission error with service principals

When using a fabric with [service principal authentication for Databricks](/data-analysis/environment/connections/databricks), you may encounter the following error:

```
Failed due to: Unable to get run status for job id: INTERNAL_ERROR
Cannot read the python file dbfs:/prophecy_tmp/prophecy_script_gem_[uuid].py
User does not have permission SELECT on ANY File
```

This occurs because the Script gem uploads Python scripts to DBFS for execution. Service principals require explicit permissions to read files from DBFS.

To solve this, contact your Databricks administrator for assistance. One workaround is to grant the service principal `SELECT` permission on `ANY FILE`:

```sql theme={null}
GRANT SELECT ON ANY FILE TO <your_service_principal_uuid>;
```

<Warning>
  Granting `SELECT ON ANY FILE` provides broad read access to the file system. Consider the security
  implications for your environment before implementing this workaround.
</Warning>
