# Project UDFs (Databricks)

You can switch project contexts and view a list of your current project or available projects through UDFs in Spark.

## Available functions

| UDF                                            | Description                                                                                                                                                                                                                                                                                                                                     |
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| immuta.set\_current\_project(id)               | Sets the user's current project to the project ID denoted by the id parameter. This UDF must be called in its own notebook cell to ensure the changes take effect.                                                                                                                                                                              |
| immuta.set\_current\_project() (no parameters) | Sets the user's current project to None.                                                                                                                                                                                                                                                                                                        |
| immuta.clear\_caches()                         | Clears all client caches for the current user's ImmutaClient instance. This can be used when a user would like to invalidate cached items, like data source subscription information or if the state of Immuta has changed and the cache is outdated. For backward compatibility, this UDF is also available at default.immuta\_clear\_caches() |
| default.immuta\_clear\_metastore\_cache()      | Clears the cluster-wide Metastore cache. This UDF can only be run by a privileged user.                                                                                                                                                                                                                                                         |

## Virtual tables

To view a list of your current project or available projects in a Spark job, you can query these virtual tables.

| Virtual Table                | Query                                       | Return                                                                                                                                                                                                                                                                                                    |
| ---------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| immuta.get\_current\_project | select \* from immuta.get\_current\_project | This virtual table returns a single row with "name" and "id" columns that show your currently selected project.                                                                                                                                                                                           |
| immuta.list\_projects        | select \* from immuta.list\_projects        | This virtual table returns rows with "name," "id," and "current\_project" columns. Each row is a different project to which you are subscribed (and can use as your current project). The "current\_project" row will be true for the row defining the project that you have set as your current project. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.immuta.com/saas/~/changes/l3NnvynMHxi6VvqRtJhK/secure-your-data/projects-and-purpose-based-access-control/write-index/reference-guides/project-udfs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
