Fix assignment of IDs to multiple relations when one of them is empty an...

...d add test for it (and in general for ID assignment)
Have we tried directly running
```
Helpers.executeCmd(s"rm -rf ${groundingPath}/dd_tmp")
Helpers.executeCmd(s"rm -f ${groundingPath}/dd_*")
```
Instead this long function? This helper function should be designed for this task unless we have compelling reasons to write a temp file for it.