Fix for SPARK-1757

I think this fixes your issue.