Class DuckDBFederationExtractor
java.lang.Object
org.odpi.openmetadata.adapters.connectors.duckdb.survey.DuckDBFederationExtractor
DuckDBFederationExtractor discovers the federation relationships that a DuckDB database makes use of:
- other databases that have been ATTACH-ed to it, discovered via DuckDB's duckdb_databases() table function
- views that scan external file/object-store resources (via functions like read_parquet(), read_csv(), read_csv_auto(), read_json(), iceberg_scan() or delta_scan()), discovered via DuckDB's duckdb_views() table function
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSimple, ordered holder for one column's name and DuckDB-reported data type, as read from duckdb_columns(). -
Constructor Summary
ConstructorsConstructorDescriptionDuckDBFederationExtractor(SurveyActionServiceConnector surveyActionServiceConnector, AuditLog auditLog, String connectorName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoiddiscoverAttachedSources(Connection databaseJDBCConnection, String primaryDatabaseName) Discover databases that have been ATTACH-ed to the DuckDB database.voiddiscoverExternalFileSources(Connection databaseJDBCConnection, String primaryDatabaseName) Discover views that scan external file/object-store resources.Return the accumulated list of federation annotations discovered so far.getColumnsForAttachedTable(Connection databaseJDBCConnection, String databaseAlias, String tableName) Retrieve the ordered list of columns (name and DuckDB-reported data type) for one table exposed by an ATTACH-ed data source, filtering duckdb_columns() by both database_name and table_name so that a table name that happens to be duplicated across several ATTACH-ed sources is not confused with the wrong one.getColumnsForTable(Connection databaseJDBCConnection, String tableName) Retrieve the ordered list of columns (name and DuckDB-reported data type) for a table or view known to DuckDB's own catalog.getTablesForAttachedDatabase(Connection databaseJDBCConnection, String databaseAlias) Retrieve the names of the tables exposed by an ATTACH-ed data source, as known to DuckDB's own catalog.
-
Constructor Details
-
DuckDBFederationExtractor
public DuckDBFederationExtractor(SurveyActionServiceConnector surveyActionServiceConnector, AuditLog auditLog, String connectorName) Constructor.- Parameters:
surveyActionServiceConnector- calling connector (used to format JSON properties)auditLog- logging destinationconnectorName- name of the calling connector - used in audit log messages
-
-
Method Details
-
discoverAttachedSources
Discover databases that have been ATTACH-ed to the DuckDB database.- Parameters:
databaseJDBCConnection- connection to the DuckDB databaseprimaryDatabaseName- name of the database being surveyed/catalogued - used only for audit log messages. This is NOT used to identify (and exclude) the "self" row in duckdb_databases(): it is Egeria's configured display name for the asset, which is independent of DuckDB's own internal database_name (always derived from the file's base name, eg "egeria_test" for "egeria_test.duckdb") - the two only match by coincidence. current_database() is queried instead to reliably identify the self row.
-
discoverExternalFileSources
public void discoverExternalFileSources(Connection databaseJDBCConnection, String primaryDatabaseName) Discover views that scan external file/object-store resources.- Parameters:
databaseJDBCConnection- connection to the DuckDB databaseprimaryDatabaseName- name of the database being surveyed/catalogued - used only for audit log messages
-
getAnnotations
Return the accumulated list of federation annotations discovered so far.- Returns:
- list of annotations (never null, but may be empty)
-
getColumnsForTable
public List<DuckDBFederationExtractor.DuckDBColumnInfo> getColumnsForTable(Connection databaseJDBCConnection, String tableName) Retrieve the ordered list of columns (name and DuckDB-reported data type) for a table or view known to DuckDB's own catalog. Used both for a DuckDB view's own columns (to model the "real" structure of the external file/object-store resource it scans) and, viagetColumnsForAttachedTable(java.sql.Connection, java.lang.String, java.lang.String), for tables exposed through an ATTACH-ed network-backed data source.- Parameters:
databaseJDBCConnection- connection to the DuckDB databasetableName- name of the table/view to retrieve columns for- Returns:
- ordered list of columns - never null, may be empty
-
getTablesForAttachedDatabase
public List<String> getTablesForAttachedDatabase(Connection databaseJDBCConnection, String databaseAlias) Retrieve the names of the tables exposed by an ATTACH-ed data source, as known to DuckDB's own catalog.- Parameters:
databaseJDBCConnection- connection to the DuckDB database (must already have re-issued the ATTACH statement that established the alias, since DuckDB does not persist ATTACH-ed data sources between sessions/connections)databaseAlias- alias the data source was ATTACH-ed under- Returns:
- list of table names - never null, may be empty
-
getColumnsForAttachedTable
public List<DuckDBFederationExtractor.DuckDBColumnInfo> getColumnsForAttachedTable(Connection databaseJDBCConnection, String databaseAlias, String tableName) Retrieve the ordered list of columns (name and DuckDB-reported data type) for one table exposed by an ATTACH-ed data source, filtering duckdb_columns() by both database_name and table_name so that a table name that happens to be duplicated across several ATTACH-ed sources is not confused with the wrong one.- Parameters:
databaseJDBCConnection- connection to the DuckDB databasedatabaseAlias- alias the data source was ATTACH-ed undertableName- name of the table to retrieve columns for- Returns:
- ordered list of columns - never null, may be empty
-