-
Notifications
You must be signed in to change notification settings - Fork 244
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
Polymorphic Lookup Data Extraction #3741
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature/load data
Revert "Polymorphic Reference - Load (merging into another branch)"
…DO-Tooling/CumulusCI into feature/polymorphic_reference
jkasturi-sf
approved these changes
Feb 5, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is to support to extract data from entities with polymorphic relations and load to other org successfully.
jkasturi-sf
pushed a commit
that referenced
this pull request
Feb 20, 2024
Fixed `INVALID_CROSS_REFERENCE` error while inserting lookups and record types simultaneously. This error appeared after [PR: Polymorphic Lookup Data Extraction](#3741). This error occurred due to mismatch in the order of fields between the step and query during generation of the json for the request.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Epic: 250 - Polymorphic data extraction
Polymorphic Lookups are references that can point to multiple SObjects. Consider the
Event
SObject, where theWhoId
field is a reference to bothContact
andLead
. Previously, CumulusCI didn't handle these polymorphic lookup fields during extraction and loading. The goal of the Epic was to include this support in CumulusCI.Old Format: (mapping.yml)
New Format: (mapping.yml)
The Epic spanned over multiple Work Items:
To accommodate polymorphic lookups for the data extraction and data loading, format of Id’s is changed while extraction. While loading to allow polymorphic fields multiple
sf_id
table were converted into singlesf_id
table. That is after the insertion, thesf_ids
are queried for the lookups and all these entries are stored in a singlesf_id
table namedcumulusci_id_table
. So, in the processing it is again a single to outer join for the polymorphic lookup field.cumulusci/tasks/bulkdata/tests/test_load.py
test_query_db__joins_polymorphic_lookups
cumulusci/tasks/bulkdata/tests/test_load.py
test_generate_contact_id_map_for_person_accounts
id
field is generated for load with both old format and new formatcumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_infer_and_validate_lookups__table_doesnt_exist
cumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_infer_and_validate_lookups__incorrect_order
cumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_infer_and_validate_lookups__after
cumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_infer_and_validate_lookups__invalid_reference
cumulusci/tasks/bulkdata/tests/test_extract.py
test_run__poly__polymorphic_lookups
cumulusci/tasks/bulkdata/tests/mapping_poly.yml
)cumulusci/tasks/bulkdata/tests/test_extract.py
test_run__poly__wrong_mapping
cumulusci/tasks/bulkdata/tests/mapping_poly_wrong.yml
)cumulusci/tasks/bulkdata/tests/test_extract.py
test_run__poly__incomplete_mapping
Contact
andLead
records and you only specifyContact
in your mapping file, it throws an error saying to mention all references for the field (mapping file:cumulusci/tasks/bulkdata/tests/mapping_poly_incomplete.yml
)cumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_get_extract_field_list
Id
first, then the other fields, then the lookup fields for theget_extract_field_list
functioncumulusci/tasks/bulkdata/tests/test_utils.py
test_create_table_modern_id_mapping
cumulusci/core/tests/test_datasets_e2e.py
test_datasets_read_explicit_extract_declaration
cumulusci/tasks/bulkdata/extract_dataset_utils/tests/test_synthesize_extract_declarations.py
test_required_lookups__pulled_in__polymorphic_lookups
Event
and fieldWhoId
, see ifContact
andLead
sobjects (which are references) are pulled in before extraction or loadcumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_generate_extract_mapping_from_declarations.py
test_generate_mapping_from_declarations__polymorphic_lookups
ExtractDeclaration
for sobjects with polymorphic lookups, see if the correct extract mapping file is getting generatedcumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_generate_load_mapping_from_declarations.py
test_generate_load_mapping_from_declarations__polymorphic_lookups
ExtractDeclaration
for sobjects with polymorphic lookups, see if the correct load mapping file is getting generatedcumulusci/tasks/bulkdata/generate_mapping_utils/tests/test_mapping_generator_post_processes.py
test_add_after_statements__polymorphic_lookups
MappingStep
with sobjects having polymorphic lookups, see if the correct after statement is getting generated. The after statement for polymorphic fields should be after the last reference sobjectcumulusci/tasks/bulkdata/tests/test_generatemapping.py
test_build_mapping__polymorphic_lookups
GenerateMapping
class.cumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_validate_and_inject_mapping_removes_lookups_with_drop_missing__polymorphic_partial_present
Contact
but notLead
and you mention theWhoId
field (of sobjectEvent
) with reference to bothContact
andLead
, ensure that it does not remove the lookup fieldcumulusci/tasks/bulkdata/tests/test_mapping_parser.py
test_validate_and_inject_mapping_removes_lookups_with_drop_missing__polymorphic_none_present
Contact
andLead
and you mention theWhoId
field (of sobjectEvent
) with reference to bothContact
andLead
, ensure that it removes the lookup field.Quip Document