Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7188#discussion_r36035504
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala 
---
    @@ -603,37 +630,41 @@ class SQLQuerySuite extends QueryTest {
         // is not in a valid state (cannot be executed). Because of this bug, 
the analysis rule of
         // PreInsertionCasts will actually start to work before 
ImplicitGenerate and then
         // generates an invalid query plan.
    -    val rdd = sparkContext.makeRDD((1 to 5).map(i => s"""{"a":[$i, ${i + 
1}]}"""))
    -    read.json(rdd).registerTempTable("data")
    -    val originalConf = convertCTAS
    -    setConf(HiveContext.CONVERT_CTAS, false)
    -
    -    sql("CREATE TABLE explodeTest (key bigInt)")
    -    table("explodeTest").queryExecution.analyzed match {
    -      case metastoreRelation: MetastoreRelation => // OK
    -      case _ =>
    -        fail("To correctly test the fix of SPARK-5875, explodeTest should 
be a MetastoreRelation")
    -    }
    +    withTable("explodeTest") {
    +      val rdd = sparkContext.makeRDD((1 to 5).map(i => s"""{"a":[$i, ${i + 
1}]}"""))
    +      read.json(rdd).registerTempTable("data")
    +      val originalConf = convertCTAS
    +      setConf(HiveContext.CONVERT_CTAS, false)
    +
    +      sql("CREATE TABLE explodeTest (key bigInt)")
    +      table("explodeTest").queryExecution.analyzed match {
    +        case metastoreRelation: MetastoreRelation => // OK
    +        case _ =>
    +          fail("To correctly test the fix of SPARK-5875, explodeTest 
should be a MetastoreRelation")
    +      }
     
    -    sql(s"INSERT OVERWRITE TABLE explodeTest SELECT explode(a) AS val FROM 
data")
    -    checkAnswer(
    -      sql("SELECT key from explodeTest"),
    -      (1 to 5).flatMap(i => Row(i) :: Row(i + 1) :: Nil)
    -    )
    +      sql(s"INSERT OVERWRITE TABLE explodeTest SELECT explode(a) AS val 
FROM data")
    +      checkAnswer(
    +        sql("SELECT key from explodeTest"),
    +        (1 to 5).flatMap(i => Row(i) :: Row(i + 1) :: Nil)
    +      )
     
    -    sql("DROP TABLE explodeTest")
    -    dropTempTable("data")
    -    setConf(HiveContext.CONVERT_CTAS, originalConf)
    +      dropTempTable("data")
    +      setConf(HiveContext.CONVERT_CTAS, originalConf)
    --- End diff --
    
    If you're going to change this code anyways, I guess that you might as well 
use `SQLTestUtils.withConf` here as well.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to