DiscoverX
Multi-table operations over the lakehouse.
Run a single command to execute operations across many tables.
Operations examples
Operations are applied concurrently across multiple tables
- Maintenance
- VACUUM all tables (example notebook)
- OPTIMIZE with z-order on tables having specified columns
- Detect tables having too many small files (example notebook)
- Visualise quantity of data written per table per period
- Governance
- PII detection with Presidio (example notebook)
- Text Analysis with MosaicML and Databricks MLflow (example notebook)
- Text Analysis with OpenAI GPT (example notebook)
- GDPR right of access: extract user data from all tables at once
- GDPR right of erasure: delete user data from all tables at once
- Search in any column
- Semantic classification
- Semantic classification of columns by semantic class: email, phone number, IP address, etc.
- Select data based on semantic classes
- Delete data based on semantic classes
- Custom
- Arbitrary SQL template execution across multiple tables
- Create Mlflow gateway routes for MosaicML and OpenAI (example notebook)
Getting started
Install DiscoverX, in Databricks notebook type
%pip install dbl-discoverx
Get started
from discoverx import DX
dx = DX(locale="US")
You can now run operations across multiple tables.
As an illustration, consider the scenario where you need to retrieve a single row from various tables within a catalog that begins with "dev_" and includes the term "sample" in their names. To achieve this, the following code block utilizes the dx.from_tables function, which applies an SQL query to extract JSON-formatted data:
dx.from_tables("dev_*.*.*sample*")\
.with_sql("SELECT to_json(struct(*)) AS row FROM {full_table_name} LIMIT 1")\
.apply()
Available functionality
The available dx functions are
from_tables("<catalog>.<schema>.<table>")selects tables based on the specified pattern (use*as a wildcard). Returns aDataExplorerobject with methodshaving_columnsrestricts the selection to tables that have the specified columnswith_concurrencydefines how many queries are executed concurrently (10 by defailt)with_sqlapplies a SQL template to all tables. After this command you can apply an action. See in-depth documentation here.unpivot_string_columnsreturns a melted (unpivoted) dataframe with all string columns from the selected tables. After this command you can apply an actionscan(experimental) scans the lakehouse with regex expressions defined by the rules and to power the semantic classification.
introgives an introduction to the libraryscanscans the lakehouse with regex expressions defined by the rules and to power the semantic classification. Documentationdisplay_rulesshows the rules available for semantic classificationsearchsearches the lakehouse content for by leveraging the semantic classes identified with scan (eg. email, ip address, etc.). Documentationselect_by_classselects data from the lakehouse content by semantic class. Documentationdelete_by_classdeletes from the lakehouse by semantic class. Documentation
from_tables Actions
After a with_sql or unpivot_string_columns command, you can apply the following actions:
explainexplains the queries that would be executeddisplayexecutes the queries and shows the first 1000 rows of the result in a unioned dataframeapplyreturns a unioned dataframe with the result from the queries
Requirements
Project Support
Please note that all projects in the /databrickslabs github account are provided for your exploration only, and are not formally supported by Databricks with Service Level Agreements (SLAs). They are provided AS-IS and we do not make any guarantees of any kind. Please do not submit a support ticket relating to any issues arising from the use of these projects.
Any issues discovered through the use of this project should be filed as GitHub Issues on the Repo. They will be reviewed as time permits, but there are no formal SLAs for support.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbl_discoverx-0.0.7.tar.gz.
File metadata
- Download URL: dbl_discoverx-0.0.7.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b370656bf00b0647c7ea47a524ccc12f74ab1262ff89e64a08dd1c5d8d487644
|
|
| MD5 |
4b67bd5e8ed7817b631e09c4724eaa01
|
|
| BLAKE2b-256 |
50cde9d5c1d1f2713bce1c042229069d78f73b94b6d17bdfd82bca82f3900880
|
File details
Details for the file dbl_discoverx-0.0.7-py3-none-any.whl.
File metadata
- Download URL: dbl_discoverx-0.0.7-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be7bf42cca1759837ad7c823a150ee86662186ed99e3e3941d1c6dc3cdbfeaff
|
|
| MD5 |
4b7bd9d8df659309495bbc3e7517d5a6
|
|
| BLAKE2b-256 |
077855bb7a6f60b6faa8793391b1ee4ed9cdac8f661b356ea697bd0f96d60129
|