pre merge from upstream for SPARK-4228