That's a Red-rumped Swallow nest. Was this in Hong Kong? They are quite rare as breeding species here.
The sparrow was probably investigating potential nest sites. I think it's possible that it would take over a swallow nest if it thought it was suitable.