SPARK-2636: refine the patch