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

    https://github.com/apache/spark/pull/15004#discussion_r78186220
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala 
---
    @@ -871,32 +871,55 @@ class DDLSuite extends QueryTest with 
SharedSQLContext with BeforeAndAfterEach {
       test("alter table: rename partition") {
         val catalog = spark.sessionState.catalog
         val tableIdent = TableIdentifier("tab1", Some("dbx"))
    -    val part1 = Map("a" -> "1", "b" -> "q")
    -    val part2 = Map("a" -> "2", "b" -> "c")
    -    val part3 = Map("a" -> "3", "b" -> "p")
    -    createDatabase(catalog, "dbx")
    -    createTable(catalog, tableIdent)
    -    createTablePartition(catalog, part1, tableIdent)
    -    createTablePartition(catalog, part2, tableIdent)
    -    createTablePartition(catalog, part3, tableIdent)
    -    assert(catalog.listPartitions(tableIdent).map(_.spec).toSet ==
    -      Set(part1, part2, part3))
    +    createPartitionedTable(tableIdent, isDatasourceTable = false)
         sql("ALTER TABLE dbx.tab1 PARTITION (a='1', b='q') RENAME TO PARTITION 
(a='100', b='p')")
    -    sql("ALTER TABLE dbx.tab1 PARTITION (a='2', b='c') RENAME TO PARTITION 
(a='200', b='c')")
    +    sql("ALTER TABLE dbx.tab1 PARTITION (a='2', b='c') RENAME TO PARTITION 
(a='20', b='c')")
         assert(catalog.listPartitions(tableIdent).map(_.spec).toSet ==
    -      Set(Map("a" -> "100", "b" -> "p"), Map("a" -> "200", "b" -> "c"), 
part3))
    +      Set(Map("a" -> "100", "b" -> "p"), Map("a" -> "20", "b" -> "c"), 
Map("a" -> "3", "b" -> "p")))
         // rename without explicitly specifying database
         catalog.setCurrentDatabase("dbx")
         sql("ALTER TABLE tab1 PARTITION (a='100', b='p') RENAME TO PARTITION 
(a='10', b='p')")
         assert(catalog.listPartitions(tableIdent).map(_.spec).toSet ==
    -      Set(Map("a" -> "10", "b" -> "p"), Map("a" -> "200", "b" -> "c"), 
part3))
    +      Set(Map("a" -> "10", "b" -> "p"), Map("a" -> "20", "b" -> "c"), 
Map("a" -> "3", "b" -> "p")))
    +    // partition to rename does not exist
    +    intercept[NoSuchPartitionException] {
    +      sql("ALTER TABLE tab1 PARTITION (a='not_found', b='1') RENAME TO 
PARTITION (a='1', b='2')")
    +    }
         // table to alter does not exist
         intercept[NoSuchTableException] {
           sql("ALTER TABLE does_not_exist PARTITION (c='3') RENAME TO 
PARTITION (c='333')")
         }
    -    // partition to rename does not exist
    --- End diff --
    
    Yeah, let me change it back.


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