Bug fix: SPARK-789

https://spark-project.atlassian.net/browse/SPARK-789
Merge pull request #674 from liancheng/master

Bug fix: SPARK-789