Skip to content

Commit 6b4fcff

Browse files
committed
Change to String type as comment suggested
1 parent c79c314 commit 6b4fcff

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalog.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ abstract class ExternalCatalog
157157
final def alterTable(tableDefinition: CatalogTable): Unit = {
158158
val db = tableDefinition.database
159159
val name = tableDefinition.identifier.table
160-
postToAll(AlterTablePreEvent(db, name, AlterTableKind.Table))
160+
postToAll(AlterTablePreEvent(db, name, AlterTableKind.TABLE))
161161
doAlterTable(tableDefinition)
162-
postToAll(AlterTableEvent(db, name, AlterTableKind.Table))
162+
postToAll(AlterTableEvent(db, name, AlterTableKind.TABLE))
163163
}
164164

165165
protected def doAlterTable(tableDefinition: CatalogTable): Unit
@@ -174,18 +174,18 @@ abstract class ExternalCatalog
174174
* @param newDataSchema Updated data schema to be used for the table.
175175
*/
176176
final def alterTableDataSchema(db: String, table: String, newDataSchema: StructType): Unit = {
177-
postToAll(AlterTablePreEvent(db, table, AlterTableKind.DataSchema))
177+
postToAll(AlterTablePreEvent(db, table, AlterTableKind.DATASCHEMA))
178178
doAlterTableDataSchema(db, table, newDataSchema)
179-
postToAll(AlterTableEvent(db, table, AlterTableKind.DataSchema))
179+
postToAll(AlterTableEvent(db, table, AlterTableKind.DATASCHEMA))
180180
}
181181

182182
protected def doAlterTableDataSchema(db: String, table: String, newDataSchema: StructType): Unit
183183

184184
/** Alter the statistics of a table. If `stats` is None, then remove all existing statistics. */
185185
final def alterTableStats(db: String, table: String, stats: Option[CatalogStatistics]): Unit = {
186-
postToAll(AlterTablePreEvent(db, table, AlterTableKind.Stats))
186+
postToAll(AlterTablePreEvent(db, table, AlterTableKind.STATS))
187187
doAlterTableStats(db, table, stats)
188-
postToAll(AlterTableEvent(db, table, AlterTableKind.Stats))
188+
postToAll(AlterTableEvent(db, table, AlterTableKind.STATS))
189189
}
190190

191191
protected def doAlterTableStats(db: String, table: String, stats: Option[CatalogStatistics]): Unit

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/events.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,13 @@ case class RenameTableEvent(
120120
extends TableEvent
121121

122122
/**
123-
* Enumeration to indicate which part of table is altered. If a plain alterTable API is called, then
123+
* String to indicate which part of table is altered. If a plain alterTable API is called, then
124124
* type will generally be Table.
125125
*/
126126
object AlterTableKind extends Enumeration {
127-
val Table, DataSchema, Stats = Value
127+
val TABLE = "table"
128+
val DATASCHEMA = "dataSchema"
129+
val STATS = "stats"
128130
}
129131

130132
/**
@@ -133,15 +135,15 @@ object AlterTableKind extends Enumeration {
133135
case class AlterTablePreEvent(
134136
database: String,
135137
name: String,
136-
kind: AlterTableKind.Value) extends TableEvent
138+
kind: String) extends TableEvent
137139

138140
/**
139141
* Event fired after a table is altered.
140142
*/
141143
case class AlterTableEvent(
142144
database: String,
143145
name: String,
144-
kind: AlterTableKind.Value) extends TableEvent
146+
kind: String) extends TableEvent
145147

146148
/**
147149
* Event fired when a function is created, dropped, altered or renamed.

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalogEventSuite.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,19 @@ class ExternalCatalogEventSuite extends SparkFunSuite {
127127
// ALTER
128128
val newTableDefinition = tableDefinition.copy(tableType = CatalogTableType.EXTERNAL)
129129
catalog.alterTable(newTableDefinition)
130-
checkEvents(AlterTablePreEvent("db5", "tbl1", AlterTableKind.Table) ::
131-
AlterTableEvent("db5", "tbl1", AlterTableKind.Table) :: Nil)
130+
checkEvents(AlterTablePreEvent("db5", "tbl1", AlterTableKind.TABLE) ::
131+
AlterTableEvent("db5", "tbl1", AlterTableKind.TABLE) :: Nil)
132132

133133
// ALTER schema
134134
val newSchema = new StructType().add("id", "long", nullable = false)
135135
catalog.alterTableDataSchema("db5", "tbl1", newSchema)
136-
checkEvents(AlterTablePreEvent("db5", "tbl1", AlterTableKind.DataSchema) ::
137-
AlterTableEvent("db5", "tbl1", AlterTableKind.DataSchema) :: Nil)
136+
checkEvents(AlterTablePreEvent("db5", "tbl1", AlterTableKind.DATASCHEMA) ::
137+
AlterTableEvent("db5", "tbl1", AlterTableKind.DATASCHEMA) :: Nil)
138138

139139
// ALTER stats
140140
catalog.alterTableStats("db5", "tbl1", None)
141-
checkEvents(AlterTablePreEvent("db5", "tbl1", AlterTableKind.Stats) ::
142-
AlterTableEvent("db5", "tbl1", AlterTableKind.Stats) :: Nil)
141+
checkEvents(AlterTablePreEvent("db5", "tbl1", AlterTableKind.STATS) ::
142+
AlterTableEvent("db5", "tbl1", AlterTableKind.STATS) :: Nil)
143143

144144
// RENAME
145145
catalog.renameTable("db5", "tbl1", "tbl2")

0 commit comments

Comments
 (0)