diff --git a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
index 9246f55020fc4f7a0f28354d785a2d845ae34092..442ae79f4f86f3062f3d4b31e842d599d0e89f05 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala
@@ -198,6 +198,9 @@ abstract class QueryTest extends PlanTest {
       case a: ImperativeAggregate => return
     }
 
+    // bypass hive tests before we fix all corner cases in hive module.
+    if (this.getClass.getName.startsWith("org.apache.spark.sql.hive")) return
+
     val jsonString = try {
       logicalPlan.toJSON
     } catch {
@@ -209,9 +212,6 @@ abstract class QueryTest extends PlanTest {
            """.stripMargin, e)
     }
 
-    // bypass hive tests before we fix all corner cases in hive module.
-    if (this.getClass.getName.startsWith("org.apache.spark.sql.hive")) return
-
     // scala function is not serializable to JSON, use null to replace them so that we can compare
     // the plans later.
     val normalized1 = logicalPlan.transformAllExpressions {