Backport of MONDRIAN-1344.