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
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
current_catalog()
current_catalog
Return type
VARCHAR
Examples
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.
SELECT current_catalog() AS result
The query returns the following result.
| result |
|---|
|
The following SQL query calls the function without parentheses, as you would in Athena engine version 3, and compares the result with current_database.
SELECT current_catalog AS result, current_catalog = current_database() AS same_as_database
The query returns the following result.
| result | same_as_database |
|---|---|
|
|
Considerations
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
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
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
current_database()
Return type
VARCHAR
Examples
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.
SELECT current_database() AS result
The query returns the following result.
| result |
|---|
|
The following SQL query shows that current_database and current_catalog return the same value.
SELECT current_database() = current_catalog() AS is_same
The query returns the following result.
| is_same |
|---|
|
Considerations
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
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
current_role()
current_role
Return type
VARCHAR
Examples
The following SQL query shows the fixed value that current_role returns. The value is the same for every IAM identity.
SELECT current_role() AS result
The query returns the following result.
| result |
|---|
|
The following SQL query calls the function without parentheses.
SELECT current_role AS result
The query returns the following result.
| result |
|---|
|
current_schema function
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
current_schema()
current_schema
Return type
VARCHAR
Examples
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.
SELECT current_schema() AS result
The query returns the following result.
| result |
|---|
|
The following SQL query calls the function without parentheses, as you would in Athena engine version 3.
SELECT current_schema AS result
The query returns the following result.
| result |
|---|
|
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.
SELECT current_schema() AS result
The query returns the following result.
| result |
|---|
|
Considerations
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
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
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
current_schemas(include_implicit)
Arguments
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
BOOLEANvalue, such astrueorfalse. A column, or another expression that is not constant, makes the query fail.
Return type
VARCHAR[]
Examples
The following SQL query returns the search path, including the schemas that the engine searches implicitly.
SELECT current_schemas(true) AS result
The query returns the following result.
| result |
|---|
|
The following SQL query shows that the list without the implicit schemas is empty. It returns the length of the list.
SELECT len(current_schemas(false)) AS result
The query returns the following result.
| result |
|---|
|
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.
SELECT current_schemas(true) AS result
The query returns the following result.
| result |
|---|
|
Considerations
The names in the list are the engine's own schemas, not AWS Glue databases.
current_user function
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
current_user()
current_user
Return type
VARCHAR
Examples
The following SQL query returns the current user name.
SELECT current_user() AS result
The query returns the following result.
| result |
|---|
|
The following SQL query calls the function without parentheses. It returns the same value as current_user().
SELECT current_user AS result
The query returns the following result.
| result |
|---|
|
Considerations
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
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
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 and the current_schema function.
Syntax
in_search_path(database_name, schema_name)
Arguments
The in_search_path function takes the following arguments:
database_name-
The name of the database, as a
VARCHARvalue. schema_name-
The name of the schema, as a
VARCHARvalue.
Return type
BOOLEAN
Examples
The following SQL query tests the current database and schema, which are always in the search path.
SELECT in_search_path( current_database(), current_schema() ) AS result
The query returns the following result.
| result |
|---|
|
The following SQL query tests a schema that does not exist, so the result is false.
SELECT in_search_path( current_database(), 'no_such_schema' ) AS result
The query returns the following result.
| result |
|---|
|
version function
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 returns the same value in its library_version column.
Syntax
version()
Return type
VARCHAR
Examples
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.
SELECT version() AS v
The query returns the following result.
| v |
|---|
|
Considerations
The PRAGMA version statement is not available, because Athena does not run PRAGMA statements. Call version() in a query instead.