For those wondering, we didn’t die mostly due to a well-placed Disintegrate. My “stick an immovable rod in its innards” was disappointingly low damage.
For those wondering otherwise, our best plan involved turning it into a regular worm, using an immovable rod with a hole drilled through the length of the staff, clicking the rod, then dispelling polymorph.
My Paladin got eaten by a purple worm once. Then spat back out. Then he jumped back inside because disadvantage and stomach acid was easier to deal with than its basic attacks.