Catalog API provides methods to manage database objects in Fenic, including catalogs, databases, tables, views, and user-defined tools. It also provides read-only access to system tables such as query metrics.
Access
Access the catalog through a session’scatalog property:
Catalog Management
create_catalog()
Creates a new catalog.Name of the catalog to create.
If
True, return False when the catalog already exists. If False, raise an error.bool - True if created successfully, False if already exists and ignore_if_exists=True
set_current_catalog()
Sets the current catalog.Name of the catalog to set as current.
get_current_catalog()
Returns the name of the current catalog. Returns:str - The current catalog name
list_catalogs()
Returns a list of available catalogs. Returns:List[str] - List of catalog names
does_catalog_exist()
Checks if a catalog exists.Name of the catalog to check.
bool - True if the catalog exists
drop_catalog()
Drops a catalog.Name of the catalog to drop.
If
True, silently return if the catalog doesn’t exist. If False, raise an error.bool - True if dropped successfully, False if didn’t exist and ignore_if_not_exists=True
Database Management
create_database()
Creates a new database.Fully qualified or relative database name to create.
If
True, return False when the database already exists. If False, raise an error.bool - True if created successfully, False if already exists and ignore_if_exists=True
set_current_database()
Sets the current database.Fully qualified or relative database name to set as current.
get_current_database()
Returns the name of the current database. Returns:str - The current database name
list_databases()
Returns a list of databases in the current catalog. Returns:List[str] - List of database names
does_database_exist()
Checks if a database exists.Fully qualified or relative database name to check.
bool - True if the database exists
drop_database()
Drops a database.Fully qualified or relative database name to drop.
If
True, drop all tables in the database.If
True, silently return if the database doesn’t exist. If False, raise an error.bool - True if dropped successfully, False if didn’t exist and ignore_if_not_exists=True
Table Management
create_table()
Creates a new table.Fully qualified or relative table name to create.
Schema of the table to create.
If
True, return False when the table already exists. If False, raise an error.Description of the table.
bool - True if created successfully, False if already exists and ignore_if_exists=True
list_tables()
Returns a list of tables in the current database. Returns:List[str] - List of table names
does_table_exist()
Checks if a table exists.Fully qualified or relative table name to check.
bool - True if the table exists
describe_table()
Returns the schema and description of a table.Fully qualified or relative table name to describe.
DatasetMetadata - Object containing schema and description
set_table_description()
Set or unset the description for a table.Fully qualified or relative table name.
The description to set for the table.
drop_table()
Drops a table.Fully qualified or relative table name to drop.
If
True, return False when the table doesn’t exist. If False, raise an error.bool - True if dropped successfully, False if didn’t exist and ignore_if_not_exists=True
View Management
list_views()
Returns a list of views in the current database. Returns:List[str] - List of view names
does_view_exist()
Checks if a view exists.Fully qualified or relative view name to check.
bool - True if the view exists
describe_view()
Returns the schema and description of a view.Fully qualified or relative view name to describe.
DatasetMetadata - Object containing schema and description
set_view_description()
Set the description for a view.Fully qualified or relative view name.
The description to set for the view.
drop_view()
Drops a view.Fully qualified or relative view name to drop.
If
True, return False when the view doesn’t exist. If False, raise an error.bool - True if dropped successfully, False if didn’t exist and ignore_if_not_exists=True
Tool Management
create_tool()
Creates a new user-defined tool in the current catalog.The name of the tool.
The description of the tool.
The query to execute when the tool is called.
The parameters of the tool.
The maximum number of rows to return from the tool.
If
True, return False when the tool already exists. If False, raise an error.bool - True if created successfully, False if already exists and ignore_if_exists=True
list_tools()
Lists the tools available in the current catalog. Returns:List[UserDefinedTool] - List of tools
describe_tool()
Returns the tool with the specified name.The name of the tool to get.
UserDefinedTool - The tool object
drop_tool()
Drops a tool from the current catalog.The name of the tool to drop.
If
True, return False when the tool doesn’t exist. If False, raise an error.bool - True if dropped successfully, False if didn’t exist and ignore_if_not_exists=True
System Tables
Query Metrics Table (Local Sessions Only)
Query metrics are recorded for each session and stored locally infenic_system.query_metrics. You can load this table into a DataFrame for analysis.
See Also
- DataFrameWriter - Write DataFrames to tables
- Schema - Define table schemas
- DataFrame - Work with DataFrames
