Backport #2363 (SPARK-3490) into branch-1.1