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

Add method to delete elements #939

Merged

Conversation

Kevin-Dekker
Copy link
Collaborator

Currently only a element by element delete method exists in the element service. This is really slow when iterating over.

The Odata v4 rest api does not support deleting multiple elements at once, so this implementation uses a workaround suggested by Hubert Heijkers (https://community.ibm.com/community/user/businessanalytics/communities/community-home/digestviewer/viewthread?GroupId=3067&MessageKey=43fd0611-5665-4367-b250-f4278dba6ac6&CommunityKey=8fde0600-e22b-4178-acf5-bf4eda43146b&tab=digestviewer). The hierarchy object is patched instead of trying to delete a collection of entities.

Currently only delete exists in the element service. This is really slow when iterating over. The Odata v4 rest api does not support deleting multiple elements at once. This implementation uses a workaround suggested by Hubert Heijkers (https://community.ibm.com/community/user/businessanalytics/communities/community-home/digestviewer/viewthread?GroupId=3067&MessageKey=43fd0611-5665-4367-b250-f4278dba6ac6&CommunityKey=8fde0600-e22b-4178-acf5-bf4eda43146b&tab=digestviewer). The hierarchy object is patched instead of trying to delete a collection of entities.
@Kevin-Dekker Kevin-Dekker requested a review from MariusWirtz July 14, 2023 13:46
@MariusWirtz
Copy link
Collaborator

Thanks for the implementation @Kevin-Dekker.
This will be useful!

The way you perform the delete is compliant with OData and the TM1py Object model, and it makes logical sense.
However, I fear that if we use an unbound TI process with a few DimensionElementDelete resp. DimensionElementDeleteDirect statements it might be much faster on large and very large dimensions.

Should we perhaps add an optional use_ti argument to this function?

@wimgielis
Copy link
Contributor

wimgielis commented Jul 16, 2023 via email

@Kevin-Dekker
Copy link
Collaborator Author

Thanks @MariusWirtz and @wimgielis,

I think we need to consider the difference between deleting elements from a dimension and deleting elements from a hierarchy. The currently suggested function only deletes elements from a specific hierarchy. The functions DimensionElementDelete, DimensionElementDeleteDirect, and DimensionDeleteElements, delete elements from the dimension rather than a specific hierarchy.

Perhaps we can default to deleting elements from the dimension when no hierarchy is specified and use the method suggested by @wimgielis through an unbound TI as Marius suggests when use_ti is passed as True?

In case use_ti is passed as False and no hierarchy_name is specified, we may need to loop over the hierarchies and use code like in the currently suggested MR to delete the elements from each hierarchy. Or will the deleting from the main hierarchy of leaves hierarchy have this effect? I could not figure this out quickly from this thread https://www.tm1forum.com/viewtopic.php?t=14882.

@josrobins
Copy link
Collaborator

Removing N level elements via the Leaves hierarchy will remove it from all hierarchies.

@MariusWirtz
Copy link
Collaborator

I think we can merge this and implement the use_ti feature in a separate branch

@MariusWirtz MariusWirtz merged commit d354d8a into cubewise-code:master Jul 21, 2023
MariusWirtz added a commit that referenced this pull request Jul 21, 2023
MariusWirtz added a commit that referenced this pull request Jul 21, 2023
MariusWirtz added a commit that referenced this pull request Aug 3, 2023
MariusWirtz added a commit that referenced this pull request Aug 3, 2023
rclapp added a commit to rclapp/TM1py that referenced this pull request Aug 3, 2023
* Add method to delete elements

Currently only delete exists in the element service. This is really slow when iterating over. The Odata v4 rest api does not support deleting multiple elements at once. This implementation uses a workaround suggested by Hubert Heijkers (https://community.ibm.com/community/user/businessanalytics/communities/community-home/digestviewer/viewthread?GroupId=3067&MessageKey=43fd0611-5665-4367-b250-f4278dba6ac6&CommunityKey=8fde0600-e22b-4178-acf5-bf4eda43146b&tab=digestviewer). The hierarchy object is patched instead of trying to delete a collection of entities.

* Asynchronous  execute_mdx_dataframe was added

* Tests were added to CellService_test.py for  execute_mdx_dataframe_async

* Update CellService.py

Don't try to write if removing non-updateable cells results in an empty set

* Delete multiple elements using TI

Successor of cubewise-code#939

---------

Co-authored-by: KDekker <kdekker@cubewise.com>
Co-authored-by: VVM <vvmits98@gmail.com>
Co-authored-by: MariusWirtz <MariusWirtz2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants