Class DuckDBDatabaseCatalogTargetProcessor


public class DuckDBDatabaseCatalogTargetProcessor extends CatalogTargetProcessorBase
DuckDBDatabaseCatalogTargetProcessor is the most novel of the DuckDB connectors. A DuckDB database is embedded (a single ".duckdb" file, or an in-memory ":memory:" session) so there is no equivalent of the "server" catalog target used by the other database connector suites for the connector to be pointed at - the catalog target configured for this processor may be any convenient, already-catalogued element (for example, a FileFolder for the directory the database file lives in, or a previous run's own DuckDB database asset); the actual identity of the DuckDB database is always (re)computed from the DuckDBConfigurationProperty.DATABASE_PATH configuration property using the files-integration-connector's FileClassifier, exactly the way DataFilesMonitorForTarget.catalogFile() computes the identity of a data file.
DESIGN NOTE (judgement call): CatalogTargetProcessorBase's contract assumes the catalog target element already exists, but the whole point of this processor is that it can materialise the RelationalDatabase asset for a DuckDB file the first time it is refreshed. This processor therefore always looks the database asset up by its FileClassifier-derived qualifiedName first (which will typically find the catalog target element itself, once it has been catalogued once) and only creates a brand-new self-anchored asset if no match is found - see getOrCreateDuckDBDatabaseAsset(String, Map).
Once the database asset's identity is settled, this processor does two more things on every refresh:
  1. hands off cataloguing of the database's native schemas/tables/columns to the "friendship" JDBC integration connector, using exactly the same catalog target hand-off mechanism as the other four vendor connector suites;
  2. catalogues DuckDB's federation relationships (databases ATTACH-ed to this one, and views that scan external files/object-store resources) - see catalogFederationRelationships(String, String, Connection). This reuses DuckDBFederationExtractor's discovery queries (its SurveyActionServiceConnector constructor parameter is unused by its query logic, so null is passed here) rather than duplicating the SQL/regex matching a second time.