Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forms) Handle deleting forms references when hard deleting forms #10820

Conversation

chriscollins3456
Copy link
Collaborator

@chriscollins3456 chriscollins3456 commented Jul 1, 2024

This PR is going to introduce a "placeholder" for how we can start handling cleaning up references to entities that are deleted. This only works for forms, but the methods are set up so that we can start handling other use cases and build this out more later.

We will come back to this and add broader support for cleaning up references, but this is a good start for forms entities.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

Summary by CodeRabbit

  • New Features

    • Enhanced the entity deletion service to include search reference deletions.
    • Added new methods to validate and handle search references during entity deletion.
  • Bug Fixes

    • Improved accuracy in deleting search references ensuring related metadata is correctly handled.
  • Refactor

    • Updated service factory to include EntitySearchService as a parameter for better modularity and scalability.

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

Walkthrough

Recent updates to DeleteEntityService add support for handling search references and metadata change proposals. The constructor and related factory now accept an EntitySearchService parameter. New methods enable the deletion of search references and propose updates to maintain data integrity during entity deletion. Enhanced test cases ensure reliable functionality and validate the handling of search references.

Changes

File Change Summary
.../entity/DeleteEntityServiceTest.java Added imports, modified constructor to accept EntitySearchService parameter, and added new test methods.
.../factory/entity/DeleteEntityServiceFactory.java Added imports and modified createDeleteEntityService() to incorporate EntitySearchService.
.../metadata/entity/DeleteEntityService.java Added imports, new class members, and methods to handle search references and metadata deletions.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant DeleteEntityService as DeleteEntityService
    participant EntitySearchService as EntitySearchService
    participant EntityService as EntityService
    participant GraphService as GraphService

    Client->>DeleteEntityService: deleteReferencesTo(urn, dryRun)
    alt dryRun is true
        DeleteEntityService->>EntitySearchService: search assets referencing urn
        DeleteEntityService->>Client: Return simulated deletion result
    else dryRun is false
        DeleteEntityService->>EntitySearchService: search assets referencing urn
        loop Over found assets
            DeleteEntityService->>EntityService: propose deletion of search references
            EntityService->>DeleteEntityService: Return deletion result
        end
        DeleteEntityService->>GraphService: update graph relationships
        DeleteEntityService->>Client: Return actual deletion result
    end
Loading

Poem

Between the data lines we sweep,
With care, the search we keep.
Deleting links, so neat and fine,
Preserving forms, a coded sign.
Through tests and checks, we dream,
Making data flow, a perfect stream. 🌟


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added product PR or Issue related to the DataHub UI/UX devops PR or Issue related to DataHub backend & deployment labels Jul 1, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3056cd8 and f9313b4.

Files selected for processing (3)
  • metadata-io/src/test/java/com/linkedin/metadata/entity/DeleteEntityServiceTest.java (4 hunks)
  • metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/DeleteEntityServiceFactory.java (2 hunks)
  • metadata-service/services/src/main/java/com/linkedin/metadata/entity/DeleteEntityService.java (7 hunks)
Additional comments not posted (31)
metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/DeleteEntityServiceFactory.java (3)

7-7: Import Approved.

The import for EntitySearchService is necessary for the new functionality.


26-28: Field Injection Approved.

The field _entitySearchService is correctly annotated with @Autowired and @Qualifier("entitySearchService").


33-33: Method Update Approved.

The method createDeleteEntityService correctly includes _entitySearchService as a parameter.

metadata-io/src/test/java/com/linkedin/metadata/entity/DeleteEntityServiceTest.java (10)

10-13: Imports Approved.

The imports for FormAssociation, FormAssociationArray, FormVerificationAssociationArray, and Forms are necessary for the new tests.


26-26: Import Approved.

The import for Filter is necessary for the new tests.


29-32: Imports Approved.

The imports for EntitySearchService, ScrollResult, SearchEntity, and SearchEntityArray are necessary for the new tests.


36-36: Import Approved.

The import for MetadataChangeProposal is necessary for the new tests.


52-52: Field Approved.

The field _mockSearchService is necessary for the new tests.


58-58: Mock Approved.

The mock for EntitySearchService is necessary for the new tests.


65-65: Constructor Update Approved.

The DeleteEntityService constructor update to include _mockSearchService is necessary for the new tests.


136-220: New Test Method Approved.

The new test method testDeleteSearchReferences is comprehensive and covers the functionality of deleting search references.


222-274: New Test Method Approved.

The new test method testDeleteNoSearchReferences is comprehensive and covers the functionality of not deleting search references when there are none.


276-333: New Test Method Approved.

The new test method testDeleteSearchReferencesDryRun is comprehensive and covers the functionality of dry-run deletion of search references.

metadata-service/services/src/main/java/com/linkedin/metadata/entity/DeleteEntityService.java (18)

9-13: Imports Approved.

The imports for FormAssociation, FormAssociationArray, FormVerificationAssociation, FormVerificationAssociationArray, and Forms are necessary for the new functionality.


30-35: Imports Approved.

The imports for Condition, ConjunctiveCriterion, ConjunctiveCriterionArray, Criterion, and CriterionArray are necessary for the new functionality.


40-42: Imports Approved.

The imports for EntitySearchService, ScrollResult, and SearchEntity are necessary for the new functionality.


47-47: Import Approved.

The import for ArrayList is necessary for the new functionality.


57-57: Import Approved.

The import for Nullable is necessary for the new functionality.


69-69: Field Approved.

The field _searchService is necessary for the new functionality.


72-72: Constant Approved.

The static constant BATCH_SIZE is necessary for the new functionality.


86-87: Reminder: Update DeleteReferencesResponse.

The TODO comment indicates that DeleteReferencesResponse needs to be updated in the future.


90-93: Method Update Approved.

The deleteReferencesTo method update to include the deleteSearchReferences call is necessary for the new functionality.


118-118: Method Update Approved.

The deleteReferencesTo method update to set the total count including totalSearchAssetCount is necessary for the new functionality.


527-549: New Method Approved.

The new method deleteSearchReferences is necessary for the new functionality.


557-638: New Method Approved.

The new method getAssetsReferencingUrn is necessary for the new functionality.


641-669: New Method Approved.

The new method deleteSearchReferencesForAsset is necessary for the new functionality.


677-682: New Method Approved.

The new method getAspectsToUpdate is necessary for the new functionality.


690-696: New Method Approved.

The new method shouldDeleteAssetReferencingUrn is necessary for the new functionality.


698-708: New Method Approved.

The new method updateAspectForSearchReference is necessary for the new functionality.


710-747: New Method Approved.

The new method updateFormsAspect is necessary for the new functionality.


749-753: New Method Approved.

The new method createAuditStamp is necessary for the new functionality.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f9313b4 and 3d68b04.

Files selected for processing (1)
  • metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/DeleteEntityServiceFactory.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • metadata-service/factories/src/main/java/com/linkedin/gms/factory/entity/DeleteEntityServiceFactory.java

@chriscollins3456 chriscollins3456 merged commit 64d4172 into datahub-project:master Jul 1, 2024
40 of 41 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops PR or Issue related to DataHub backend & deployment product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants