cloud-fan commented on a change in pull request #30089:
URL: https://github.com/apache/spark/pull/30089#discussion_r509948969
##########
File path:
external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/V2JDBCTest.scala
##########
@@ -55,7 +55,54 @@ trait V2JDBCTest extends SharedSparkSession {
assert(msg.contains("Table not found"))
}
- test("SPARK-33034: ALTER TABLE ... update column type") {
+ test("ALTER TABLE ... rename column") {
+ withTable(s"$catalogName.alt_table") {
+ sql(s"CREATE TABLE $catalogName.alt_table (id INTEGER, C0 INTEGER) USING
_")
+ sql(s"ALTER TABLE $catalogName.alt_table RENAME COLUMN id TO C")
+ val t = spark.table(s"$catalogName.alt_table")
+ val expectedSchema = catalogName match {
+ case "oracle" => new StructType().add("C", DecimalType(10,
0)).add("C0", DecimalType(10, 0))
+ case _ => new StructType().add("C", IntegerType).add("C0", IntegerType)
+ }
+ assert(t.schema === expectedSchema)
+ // Rename to already existing column
+ val msg = intercept[AnalysisException] {
+ sql(s"ALTER TABLE $catalogName.alt_table RENAME COLUMN C TO C0")
+ }.getMessage
+ assert(msg.contains("Cannot rename column, because C0 already exists"))
+ }
+ // Rename a column in a not existing table
+ val msg = intercept[AnalysisException] {
+ sql(s"ALTER TABLE $catalogName.not_existing_table RENAME COLUMN ID TO C")
+ }.getMessage
+ assert(msg.contains("Table not found"))
+ }
+
+ test("ALTER TABLE ... drop column") {
+ withTable(s"$catalogName.alt_table") {
+ sql(s"CREATE TABLE $catalogName.alt_table (C1 INTEGER, C2 INTEGER, c3
INTEGER) USING _")
+ sql(s"ALTER TABLE $catalogName.alt_table DROP COLUMN C1")
+ sql(s"ALTER TABLE $catalogName.alt_table DROP COLUMN c3")
+ val t = spark.table(s"$catalogName.alt_table")
+ val expectedSchema = catalogName match {
+ case "oracle" => new StructType().add("C2", DecimalType(10, 0))
Review comment:
what happens in Oracle?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]