SPARK-3807: Add a test case to validate the fix.