[SPARK-2729][SQL] Added test case for SPARK-2729

This is a follow up of #1636.