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

    https://github.com/apache/spark/pull/6318#discussion_r31124181
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala 
---
    @@ -814,4 +814,40 @@ class SQLQuerySuite extends QueryTest {
           sql("SELECT cast(key+2 as Int) from df_analysis A group by 
cast(key+1 as int)")
         }
       }
    +
    +  test("dynamic partition value test") {
    +    try {
    +      sql("set hive.exec.dynamic.partition.mode=nonstrict")
    +      // date
    +      sql("drop table if exists dynparttest1")
    +      sql("create table dynparttest1 (value int) partitioned by (pdate 
date)")
    +      sql(
    +        """
    +        |insert into table dynparttest1 partition(pdate)
    +        | select count(*), cast('2015-05-21' as date) as pdate from src
    +      """.stripMargin)
    +      checkAnswer(
    +      sql(
    +        "select * from dynparttest1"),
    +        Seq(Row(500, java.sql.Date.valueOf("2015-05-21"))))
    +
    +      // decimal
    +      sql("drop table if exists dynparttest3")
    +      sql("create table dynparttest3 (value int) partitioned by (pdec 
decimal(5, 1))")
    +      sql(
    +        """
    +          |insert into table dynparttest3 partition(pdec)
    +          | select count(*), cast('100.12' as decimal(5, 1)) as pdec from 
src
    +        """.stripMargin)
    +      checkAnswer(
    +        sql(
    +          "select * from dynparttest3"),
    +        Seq(Row(500, new java.math.BigDecimal("100.1"))))
    +    } finally {
    +      sql("drop table if exists dynparttest1")
    +      sql("drop table if exists dynparttest2")
    +      sql("drop table if exists dynparttest3")
    +      sql("set hive.exec.dynamic.partition.mode=strict")
    --- End diff --
    
    `SQLTestUtils` provides several utility methods to help eliminating cleanup 
code like this. For example, you may use the following to simplify this test 
case:
    
    ```scala
    withSQLConf("hive.exec.dynamic.partition.mode" -> "strict") {
      withTable("dynparttest1", "dynparttest2", "dynparttest3") {
        // ...
      }
    }
    ```


---
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