@@ -19,7 +19,7 @@ package org.apache.spark.sql.catalyst.catalog
1919
2020import java .util .concurrent .ConcurrentHashMap
2121
22- import org .apache .spark .sql .catalyst .TableIdentifier
22+ import org .apache .spark .sql .catalyst .{ FunctionIdentifier , TableIdentifier }
2323import org .apache .spark .sql .catalyst .plans .logical .LogicalPlan
2424
2525
@@ -64,6 +64,8 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
6464 // sessions as their metadata is persisted in the underlying catalog.
6565 // ----------------------------------------------------------------------------
6666
67+ // Methods that interact with metastore tables only.
68+
6769 /**
6870 * Create a metastore table in the database specified in `tableDefinition`.
6971 * If no such table is specified, create it in the current database.
@@ -84,7 +86,9 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
8486 /**
8587 * Retrieve the metadata of an existing metastore table.
8688 */
87- def getTableMetadata (name : TableIdentifier ): CatalogTable
89+ def getTable (name : TableIdentifier ): CatalogTable
90+
91+ // Methods that interact with temporary tables and metastore tables.
8892
8993 /**
9094 * Create a temporary table.
@@ -140,24 +144,27 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
140144 */
141145 def listTables (currentDb : String , pattern : String ): Seq [TableIdentifier ]
142146
143- // --------------------------------------------------------------------------
147+ // ----------------------------------------------------------------------------
144148 // Partitions
149+ // ----------------------------------------------------------------------------
145150 // All methods in this category interact directly with the underlying catalog.
146- // --------------------------------------------------------------------------
147- // TODO: We need to figure out how these methods interact with our data source tables.
148- // For data source tables, we do not store values of partitioning columns in the metastore.
149- // For now, partition values of a data source table will be automatically discovered
150- // when we load the table.
151+ // These methods are concerned with only metastore tables.
152+ // ----------------------------------------------------------------------------
153+
154+ // TODO: We need to figure out how these methods interact with our data source
155+ // tables. For such tables, we do not store values of partitioning columns in
156+ // the metastore. For now, partition values of a data source table will be
157+ // automatically discovered when we load the table.
151158
152159 def createPartitions (
153- db : String ,
154- table : String ,
160+ currentDb : String ,
161+ tableName : TableIdentifier ,
155162 parts : Seq [CatalogTablePartition ],
156163 ignoreIfExists : Boolean ): Unit
157164
158165 def dropPartitions (
159- db : String ,
160- table : String ,
166+ currentDb : String ,
167+ tableName : TableIdentifier ,
161168 parts : Seq [TablePartitionSpec ],
162169 ignoreIfNotExists : Boolean ): Unit
163170
@@ -166,8 +173,8 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
166173 * This assumes index i of `specs` corresponds to index i of `newSpecs`.
167174 */
168175 def renamePartitions (
169- db : String ,
170- table : String ,
176+ currentDb : String ,
177+ tableName : TableIdentifier ,
171178 specs : Seq [TablePartitionSpec ],
172179 newSpecs : Seq [TablePartitionSpec ]): Unit
173180
@@ -179,69 +186,59 @@ abstract class SessionCatalog(catalog: ExternalCatalog) {
179186 * this becomes a no-op.
180187 */
181188 def alterPartitions (
182- db : String ,
183- table : String ,
189+ currentDb : String ,
190+ tableName : TableIdentifier ,
184191 parts : Seq [CatalogTablePartition ]): Unit
185192
186- def getPartition (db : String , table : String , spec : TablePartitionSpec ): CatalogTablePartition
193+ def getPartition (
194+ currentDb : String ,
195+ tableName : TableIdentifier ,
196+ spec : TablePartitionSpec ): CatalogTablePartition
187197
188- def listPartitions (db : String , table : String ): Seq [CatalogTablePartition ]
198+ def listPartitions (
199+ currentDb : String ,
200+ tableName : TableIdentifier ): Seq [CatalogTablePartition ]
189201
190- // --------------------------------------------------------------------------
202+ // ----------------------------------------------------------------------------
191203 // Functions
192- // --------------------------------------------------------------------------
204+ // ----------------------------------------------------------------------------
205+ // There are two kinds of functions, temporary functions and metastore
206+ // functions (permanent UDFs). Temporary functions are isolated across
207+ // sessions. Metastore functions can be used across multiple sessions as
208+ // their metadata is persisted in the underlying catalog.
209+ // ----------------------------------------------------------------------------
210+
211+ // Methods that interact with metastore functions only.
193212
194- // --------------------------------------------------------------------------
195- // Functions: Methods for metastore functions (permanent UDFs).
196- // --------------------------------------------------------------------------
213+ def createFunction (currentDb : String , funcDefinition : CatalogFunction ): Unit
197214
198- def createFunction ( db : String , funcDefinition : CatalogFunction ): Unit
215+ def dropFunction ( currentDb : String , funcName : FunctionIdentifier ): Unit
199216
200217 /**
201- * Drops a permanent function with the given name from the given database.
218+ * Alter a function whose name that matches the one specified in `funcDefinition`,
219+ * assuming the function exists.
220+ *
221+ * Note: If the underlying implementation does not support altering a certain field,
222+ * this becomes a no-op.
202223 */
203- def dropFunction ( db : String , funcName : String ): Unit
224+ def alterFunction ( currentDb : String , funcDefinition : CatalogFunction ): Unit
204225
205- // --------------------------------------------------------------------------
206- // Functions: Methods for metastore functions (permanent UDFs) or temp functions.
207- // --------------------------------------------------------------------------
226+ // Methods that interact with temporary functions and metastore functions.
208227
209228 def createTempFunction (funcDefinition : CatalogFunction ): Unit
210229
211- /**
212- * Drops a temporary function with the given name.
213- */
214230 // TODO: The reason that we distinguish dropFunction and dropTempFunction is that
215231 // Hive has DROP FUNCTION and DROP TEMPORARY FUNCTION. We may want to consolidate
216232 // dropFunction and dropTempFunction.
217233 def dropTempFunction (funcName : String ): Unit
218234
219235 def renameFunction (
220- specifiedDB : Option [String ],
221- currentDB : String ,
222- oldName : String ,
223- newName : String ): Unit
236+ currentDb : String ,
237+ oldName : FunctionIdentifier ,
238+ newName : FunctionIdentifier ): Unit
224239
225- /**
226- * Alter a function whose name that matches the one specified in `funcDefinition`,
227- * assuming the function exists.
228- *
229- * Note: If the underlying implementation does not support altering a certain field,
230- * this becomes a no-op.
231- */
232- def alterFunction (
233- specifiedDB : Option [String ],
234- currentDB : String ,
235- funcDefinition : CatalogFunction ): Unit
236-
237- def getFunction (
238- specifiedDB : Option [String ],
239- currentDB : String ,
240- funcName : String ): CatalogFunction
241-
242- def listFunctions (
243- specifiedDB : Option [String ],
244- currentDB : String ,
245- pattern : String ): Seq [String ]
240+ def getFunction (currentDb : String , funcIdentifier : FunctionIdentifier ): CatalogFunction
241+
242+ def listFunctions (currentDb : String , pattern : String ): Seq [FunctionIdentifier ]
246243
247244}
0 commit comments