AI-Assisted Primary Key Detection and Uniqueness Rules Generation#934
Conversation
|
✅ 443/443 passed, 1 flaky, 41 skipped, 3h4m20s total Flaky tests:
Running from acceptance #3280 |
Looking at the cyclic import warnings, these are pre-existing architectural issues in the codebase, not caused by our changes. They all appear in tests/e2e/test_pii_detection_checks.py. However, we can disable the cyclic-import warning globally since: These are complex architectural dependencies
There was a problem hiding this comment.
Pull Request Overview
This PR introduces LLM-based primary key detection functionality for the dqx library, enabling automatic identification of primary key columns in database tables using AI analysis.
Key changes:
- Added
DatabricksPrimaryKeyDetectorclass for LLM-powered primary key detection with duplicate validation and retry logic - Integrated PK detection into the profiler workflow via
ProfilerRunner - Created
compare_datasets_with_llmwrapper function that auto-detects primary keys for dataset comparison
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/databricks/labs/dqx/llm/llm_pk_detector.py | Core implementation of DSPy-based primary key detector with Databricks integration |
| src/databricks/labs/dqx/profiler/generator.py | Added detect_primary_keys_with_llm method to DQGenerator |
| src/databricks/labs/dqx/profiler/profiler.py | Added convenience method for PK detection via DQProfiler |
| src/databricks/labs/dqx/profiler/profiler_runner.py | Integrated automatic PK detection into profiler workflow |
| src/databricks/labs/dqx/check_funcs.py | Added wrapper function for dataset comparison with auto PK detection |
| src/databricks/labs/dqx/llm/init.py | Updated LLM dependencies to include langchain packages |
| tests/unit/test_llm_pk_integration.py | Unit tests for LLM PK detection functionality |
| tests/integration/test_llm_pk_detection.py | Integration tests for end-to-end PK detection |
| pyproject.toml | Updated dependencies and pylint configuration |
| demos/dqx_demo_llm_pk_detection.py | Demo notebook showcasing PK detection capabilities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…slabs/dqx into llm_based_pk_detection
refactor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 45 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
tests/integration/test_dlt_rules_generator.py:1
- Import path
tests.integration.test_generatoris incorrect. The module should betests.integration.test_rules_generatorbased on the file structure visible in the diffs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 45 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
tests/integration/test_dlt_rules_generator.py:1
- Import path is incorrect. The module
test_generatordoes not exist - it should betest_rules_generatorbased on the file being renamed from.
tests/unit/test_llm_pk_detector.py:1 - These helper functions
_create_mock_detector_resultand_create_mock_spark_resultsare defined but never used in any of the tests. Consider removing them to reduce code clutter, or add tests that utilize these helpers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Changes
detect_primary_keys_with_llmmethod to theDQProfiler.DQGeneratorto leverage uniqueness profiles from the profiler.BREAKING CHANGES!
levelparameter tocriticalityingenerate_dq_rules methodinDQGeneratorfor consistency.table: strparameter withinput_config: InputConfiginprofile_tablemethod ofDQProfilerfor greater flexibility.Linked issues
Resolves #484
Tests