Area: Ingestion Issues
Sub-Area: Oracle Connector, Usage Ingestion Filtering and URN Resolution
Applies to: OSS + Cloud
Issue
You run the Oracle source with include_query_usage: true and with schema_pattern, table_pattern or view_pattern filters. After the run, DataHub shows Oracle datasets you did not expect:
- Datasets for tables that your filters exclude. They have usage, operations or queries, but no schema container.
- A second browse group under the Oracle platform, named after your database, that holds three-part
database.schema.tabledatasets with no container. Your crawled datasets sit elsewhere as two-partschema.tabledatasets.
DataHub prints no error for this. The extra datasets are the only sign.
You Might Be Asking
- Why do datasets outside my
schema_patternandtable_patternfilters show up in DataHub? - Why do some Oracle datasets have usage statistics but no container?
- Why is there an extra browse group named after my Oracle database?
- How do I remove the orphan Oracle datasets that earlier runs created?
Cause
With include_query_usage: true, the Oracle source reads SQL statements from Oracle's V$SQL view and parses them. Before the fix, this path had two bugs.
-
No filters on query usage. The SQL parsing step did not apply
schema_pattern,table_patternorview_patternto the tables a statement references. Every referenced table got usage, operations and query subjects, including tables your recipe excludes. The schema crawl never visited those tables, so their datasets have no container. -
URN mismatch. The parser filled in a missing database name with the database name it detected in Oracle. This put usage on three-part
<detected database>.schema.tableURNs while the crawl emitted two-partschema.tableURNs. Two recipe setups hit this:- the default
add_database_name_to_urn: false -
add_database_name_to_urn: truewithservice_nameand nourn_db_name
DataHub treats the three-part and two-part URNs as different datasets, so the usage landed on a separate, container-less set of datasets.
- the default
Recipes with add_database_name_to_urn: true plus database or urn_db_name were not affected by the URN mismatch. Their crawl already emits three-part URNs.
Solution
1. Upgrade the CLI
Both bugs are fixed in acryl-datahub 1.7.0.20. After you upgrade:
- Usage, operations and query subjects from V$SQL respect
schema_pattern,table_patternandview_pattern. - Filtering works per table, not per statement. If one statement reads an in-scope table and an excluded table, the in-scope table still gets its usage.
- Usage goes to the same dataset URNs that the schema crawl emits. On the next run, usage moves to your crawled datasets.
A table passes the filter when either table_pattern or view_pattern allows it, because the SQL parser cannot tell tables from views. If you leave view_pattern unset, it copies table_pattern. If you set view_pattern yourself, add your table denies to it too.
For DataHub Cloud managed ingestion, open the ingestion source, go to Advanced Settings, and set CLI Version to 1.7.0.20.
For CLI ingestion:
pip install 'acryl-datahub[oracle]==1.7.0.20'
See the Oracle source documentation for the filter and URN options, and the #20462 entry in Breaking Changes for the change notes.
2. Interim workaround if you can't upgrade yet
query_exclude_patterns takes a list of regex patterns (up to 100). The source drops any V$SQL statement whose text matches one of them, case-insensitive.
source:
type: oracle
config:
# ... other config ...
include_query_usage: true
query_exclude_patterns:
- 'FROM\s+<excluded_schema>\.'
- 'JOIN\s+<excluded_schema>\.'
This workaround has limits:
- It drops the whole statement, so in-scope tables in the same statement lose that usage too.
- It does not catch statements that reference a table without the schema prefix.
- It does nothing for the URN mismatch. Usage for in-scope tables still lands on the three-part, container-less datasets.
Upgrading is the real fix.
3. Clean up orphan datasets from earlier runs
Upgrading stops new orphans. It does not remove the ones earlier runs created.
Only the two setups listed in Cause left orphan three-part datasets. If your recipe ran with add_database_name_to_urn: true and database or urn_db_name, your three-part datasets are real. Don't delete them.
First, list what would be deleted. --dry-run prints the matching entities and deletes nothing:
datahub delete --platform oracle --entity-type dataset --query '<detected database>.*' --dry-run
--query can select more entities than you expect. Check the match count and every URN in the dry-run output. Make sure the list holds only the orphans.
Then run the same command without --dry-run:
datahub delete --platform oracle --entity-type dataset --query '<detected database>.*'
datahub delete does a soft delete by default. It hides the datasets in the UI and keeps them in the database. To restore one you deleted by mistake:
datahub delete undo-by-filter --urn '<dataset urn>'
Restore it soon. DataHub's garbage collection job hard-deletes soft-deleted entities after 10 days by default. After a hard delete, any documentation, owners or tags you added in the UI are gone.
For orphans that match none of your filters (the out-of-filter tables), build the --query from their schema or table names and follow the same dry-run steps. See Removing Metadata from DataHub for all delete options.