

# Session information functions

Use these functions to read the user, database, schema, and search path of the engine session that runs your query, and the release line of the engine. These values come from the engine itself, not from the query execution context, so they do not name your AWS Glue database, your catalog, or your IAM identity.

## `current_catalog` function
<a name="athena-duckdb-functions-utility-current-catalog"></a>

Returns the name of the database that the engine uses by default, as a `VARCHAR` value. In DuckDB, the result is `memory`, the name of the engine's own database. The value comes from the engine session that runs the query. It is not the name of an AWS Glue database. It is also not the name of the catalog that Athena uses for your table names, such as `AwsDataCatalog`.

`current_catalog` returns the same value as `current_database`. You can call it with or without parentheses.

### Syntax
<a name="athena-duckdb-functions-utility-current-catalog-syntax"></a>

```sql
current_catalog()
current_catalog
```

### Return type
<a name="athena-duckdb-functions-utility-current-catalog-return-type"></a>

`VARCHAR`

### Examples
<a name="athena-duckdb-functions-utility-current-catalog-examples"></a>

The following SQL query shows the value that `current_catalog` returns. It is the name of the engine's own database, not the name of the catalog that your query uses.

```sql
SELECT current_catalog() AS result
```

The query returns the following result.


| result | 
| --- | 
| `memory` | 

The following SQL query calls the function without parentheses, as you would in Athena engine version 3, and compares the result with `current_database`.

```sql
SELECT
    current_catalog AS result,
    current_catalog = current_database() AS same_as_database
```

The query returns the following result.


| result | same\_as\_database | 
| --- | --- | 
| `memory` | `true` | 

### Considerations
<a name="athena-duckdb-functions-utility-current-catalog-considerations"></a>

To find out which catalog Athena uses for a table name that does not name a catalog, check the query execution context of the query. If the context does not set a catalog, Athena uses `AwsDataCatalog`. `current_catalog` does not report it.

### Differences from Athena engine version 3
<a name="athena-duckdb-functions-utility-current-catalog-differences-from-engine-version-3"></a>

In Athena engine version 3, `current_catalog` returns the catalog of the query, for example `awsdatacatalog`. In DuckDB, it returns the name of the engine's own database, `memory`.

## `current_database` function
<a name="athena-duckdb-functions-utility-current-database"></a>

Returns the name of the database that the engine uses by default, as a `VARCHAR` value. In DuckDB, the result is `memory`, the name of the engine's own database. The value comes from the engine session that runs the query.

In DuckDB, what Athena calls a database is called a schema, and a database is at the same level as a catalog. For this reason, `current_database` returns neither the name of an AWS Glue database nor the name of the catalog that Athena uses for your table names. The `current_catalog` function returns the same value.

### Syntax
<a name="athena-duckdb-functions-utility-current-database-syntax"></a>

```sql
current_database()
```

### Return type
<a name="athena-duckdb-functions-utility-current-database-return-type"></a>

`VARCHAR`

### Examples
<a name="athena-duckdb-functions-utility-current-database-examples"></a>

The following SQL query shows the value that `current_database` returns. It is the name of the engine's own database, not the name of an AWS Glue database.

```sql
SELECT current_database() AS result
```

The query returns the following result.


| result | 
| --- | 
| `memory` | 

The following SQL query shows that `current_database` and `current_catalog` return the same value.

```sql
SELECT current_database() = current_catalog() AS is_same
```

The query returns the following result.


| is\_same | 
| --- | 
| `true` | 

### Considerations
<a name="athena-duckdb-functions-utility-current-database-considerations"></a>

Write the parentheses. Unlike `current_catalog` and `current_schema`, `current_database` without parentheses is read as a column name, and the query fails if there is no such column.

## `current_role` function
<a name="athena-duckdb-functions-utility-current-role"></a>

Returns the fixed `VARCHAR` value `duckdb`. The function exists so that SQL that calls it still runs. The value comes from the engine session that runs the query. It does not identify the IAM role or any other AWS identity that runs the query. You can call it with or without parentheses.

### Syntax
<a name="athena-duckdb-functions-utility-current-role-syntax"></a>

```sql
current_role()
current_role
```

### Return type
<a name="athena-duckdb-functions-utility-current-role-return-type"></a>

`VARCHAR`

### Examples
<a name="athena-duckdb-functions-utility-current-role-examples"></a>

The following SQL query shows the fixed value that `current_role` returns. The value is the same for every IAM identity.

```sql
SELECT current_role() AS result
```

The query returns the following result.


| result | 
| --- | 
| `duckdb` | 

The following SQL query calls the function without parentheses.

```sql
SELECT current_role AS result
```

The query returns the following result.


| result | 
| --- | 
| `duckdb` | 

## `current_schema` function
<a name="athena-duckdb-functions-utility-current-schema"></a>

Returns the name of the schema that the engine uses by default, as a `VARCHAR` value. In DuckDB, the result is `main`, the default schema of the engine's own database. The value comes from the engine session that runs the query.

In DuckDB, an AWS Glue database is called a schema, but `current_schema` does not return the name of an AWS Glue database. In particular, it does not return the database that Athena uses for table names that do not name a database. You can call the function with or without parentheses.

### Syntax
<a name="athena-duckdb-functions-utility-current-schema-syntax"></a>

```sql
current_schema()
current_schema
```

### Return type
<a name="athena-duckdb-functions-utility-current-schema-return-type"></a>

`VARCHAR`

### Examples
<a name="athena-duckdb-functions-utility-current-schema-examples"></a>

The following SQL query shows the value that `current_schema` returns. It is the name of the engine's own default schema, not the name of the database that your query uses.

```sql
SELECT current_schema() AS result
```

The query returns the following result.


| result | 
| --- | 
| `main` | 

The following SQL query calls the function without parentheses, as you would in Athena engine version 3.

```sql
SELECT current_schema AS result
```

The query returns the following result.


| result | 
| --- | 
| `main` | 

The following SQL query runs with `sales_db` as the database that your query uses. This is the same as choosing `sales_db` in the query editor or setting `Database` in the query execution context. The result is still `main`, so `sales_db` does not change the value that `current_schema` returns.

```sql
SELECT current_schema() AS result
```

The query returns the following result.


| result | 
| --- | 
| `main` | 

### Considerations
<a name="athena-duckdb-functions-utility-current-schema-considerations"></a>

To find out which database Athena uses for a table name that does not name a database, check the query execution context of the query. If the context does not set a database, Athena uses `default`. `current_schema` does not report it.

### Differences from Athena engine version 3
<a name="athena-duckdb-functions-utility-current-schema-differences-from-engine-version-3"></a>

In Athena engine version 3, `current_schema` returns the database of the query, which comes from the query execution context. In DuckDB, it returns `main`, the default schema of the engine's own database.

## `current_schemas` function
<a name="athena-duckdb-functions-utility-current-schemas"></a>

Returns a list of the names of the schemas that the engine searches when a query names a table or function without its schema. When `include_implicit` is `true`, the list also includes the schemas that the engine searches implicitly. The list holds schema names only, so the same name, such as `main`, can appear more than once. The list comes from the engine session that runs the query.

When `include_implicit` is `false`, the list holds only the schemas that were added to the search path explicitly. Because DuckDB does not run `SET` statements, you cannot add schemas to the search path, and this list is empty. If `include_implicit` is `NULL`, the result is `NULL`.

### Syntax
<a name="athena-duckdb-functions-utility-current-schemas-syntax"></a>

```sql
current_schemas({{include_implicit}})
```

### Arguments
<a name="athena-duckdb-functions-utility-current-schemas-arguments"></a>

The `current_schemas` function takes the following argument:

**{{include\_implicit}}**  
A flag that says whether the list also includes the schemas that the engine searches implicitly. It must be a constant `BOOLEAN` value, such as `true` or `false`. A column, or another expression that is not constant, makes the query fail.

### Return type
<a name="athena-duckdb-functions-utility-current-schemas-return-type"></a>

`VARCHAR[]`

### Examples
<a name="athena-duckdb-functions-utility-current-schemas-examples"></a>

The following SQL query returns the search path, including the schemas that the engine searches implicitly.

```sql
SELECT current_schemas(true) AS result
```

The query returns the following result.


| result | 
| --- | 
| `[main, main, main, pg_catalog]` | 

The following SQL query shows that the list without the implicit schemas is empty. It returns the length of the list.

```sql
SELECT len(current_schemas(false)) AS result
```

The query returns the following result.


| result | 
| --- | 
| `0` | 

The following SQL query runs with `sales_db` as the database that your query uses. You get the same database when you choose `sales_db` in the query editor or set `Database` in the query execution context. The list is the same as when the context does not set a database, so `sales_db` does not change the search path that `current_schemas` returns.

```sql
SELECT current_schemas(true) AS result
```

The query returns the following result.


| result | 
| --- | 
| `[main, main, main, pg_catalog]` | 

### Considerations
<a name="athena-duckdb-functions-utility-current-schemas-considerations"></a>

The names in the list are the engine's own schemas, not AWS Glue databases.

## `current_user` function
<a name="athena-duckdb-functions-utility-current-user"></a>

Returns the name of the engine's current user, as a `VARCHAR`. In DuckDB, the result is always `duckdb`. The value comes from the engine session that runs the query. It does not identify the AWS account, the IAM principal, or the workgroup that the query runs in.

You can call the function with or without parentheses. `current_user()` and `current_user` return the same value.

`session_user` and `user` are aliases of `current_user`.

### Syntax
<a name="athena-duckdb-functions-utility-current-user-syntax"></a>

```sql
current_user()
current_user
```

### Return type
<a name="athena-duckdb-functions-utility-current-user-return-type"></a>

`VARCHAR`

### Examples
<a name="athena-duckdb-functions-utility-current-user-examples"></a>

The following SQL query returns the current user name.

```sql
SELECT current_user() AS result
```

The query returns the following result.


| result | 
| --- | 
| `duckdb` | 

The following SQL query calls the function without parentheses. It returns the same value as `current_user()`.

```sql
SELECT current_user AS result
```

The query returns the following result.


| result | 
| --- | 
| `duckdb` | 

### Considerations
<a name="athena-duckdb-functions-utility-current-user-considerations"></a>

Every query gets the same value, so do not use `current_user` to filter rows by user or to record who ran a query.

### Differences from Athena engine version 3
<a name="athena-duckdb-functions-utility-current-user-differences-from-engine-version-3"></a>

In Athena engine version 3, `current_user` returns the name of the user who runs the query. In DuckDB, it always returns `duckdb`.

## `in_search_path` function
<a name="athena-duckdb-functions-utility-in-search-path"></a>

Returns `true` if the schema `schema_name` of the database `database_name` is in the search path of the current session, and `false` if it is not. The search path is the list of schemas that the engine looks in when a name does not say which schema it belongs to. If either argument is `NULL`, the result is `NULL`.

The search path belongs to the engine session that runs the query. It holds the engine's own schemas, not AWS Glue databases. To see the names of the engine's own database and schema, use the [`current_database` function](#athena-duckdb-functions-utility-current-database) and the [`current_schema` function](#athena-duckdb-functions-utility-current-schema).

### Syntax
<a name="athena-duckdb-functions-utility-in-search-path-syntax"></a>

```sql
in_search_path({{database_name}}, {{schema_name}})
```

### Arguments
<a name="athena-duckdb-functions-utility-in-search-path-arguments"></a>

The `in_search_path` function takes the following arguments:

**{{database\_name}}**  
The name of the database, as a `VARCHAR` value.

**{{schema\_name}}**  
The name of the schema, as a `VARCHAR` value.

### Return type
<a name="athena-duckdb-functions-utility-in-search-path-return-type"></a>

`BOOLEAN`

### Examples
<a name="athena-duckdb-functions-utility-in-search-path-examples"></a>

The following SQL query tests the current database and schema, which are always in the search path.

```sql
SELECT
    in_search_path(
        current_database(), current_schema()
    ) AS result
```

The query returns the following result.


| result | 
| --- | 
| `true` | 

The following SQL query tests a schema that does not exist, so the result is `false`.

```sql
SELECT
    in_search_path(
        current_database(), 'no_such_schema'
    ) AS result
```

The query returns the following result.


| result | 
| --- | 
| `false` | 

## `version` function
<a name="athena-duckdb-functions-utility-version"></a>

Returns the release line of open-source DuckDB that the engine is built from, as a `VARCHAR` value. The value names only the release line, not an exact engine build.

The [`pragma_version` function](duckdb-functions-table-catalog-and-system.md#athena-duckdb-functions-table-pragma-version) returns the same value in its `library_version` column.

### Syntax
<a name="athena-duckdb-functions-utility-version-syntax"></a>

```sql
version()
```

### Return type
<a name="athena-duckdb-functions-utility-version-return-type"></a>

`VARCHAR`

### Examples
<a name="athena-duckdb-functions-utility-version-examples"></a>

The following SQL query returns the release line of open-source DuckDB that the engine is built from. The value changes when the engine moves to a newer release line.

```sql
SELECT version() AS v
```

The query returns the following result.


| v | 
| --- | 
| `v2.0-cyanoptera` | 

### Considerations
<a name="athena-duckdb-functions-utility-version-considerations"></a>

The `PRAGMA version` statement is not available, because Athena does not run `PRAGMA` statements. Call `version()` in a query instead.