|
17 | 17 |
|
18 | 18 | package org.apache.spark.sql.catalog |
19 | 19 |
|
| 20 | +import scala.collection.JavaConverters._ |
| 21 | + |
20 | 22 | import org.apache.spark.annotation.{Experimental, InterfaceStability} |
21 | 23 | import org.apache.spark.sql.{AnalysisException, DataFrame, Dataset} |
22 | 24 | import org.apache.spark.sql.types.StructType |
@@ -187,82 +189,169 @@ abstract class Catalog { |
187 | 189 | def functionExists(dbName: String, functionName: String): Boolean |
188 | 190 |
|
189 | 191 | /** |
190 | | - * :: Experimental :: |
191 | | - * Creates an external table from the given path and returns the corresponding DataFrame. |
| 192 | + * Creates a table from the given path and returns the corresponding DataFrame. |
192 | 193 | * It will use the default data source configured by spark.sql.sources.default. |
193 | 194 | * |
194 | 195 | * @since 2.0.0 |
195 | 196 | */ |
| 197 | + @deprecated("use createTable instead.", "2.2.0") |
| 198 | + def createExternalTable(tableName: String, path: String): DataFrame = { |
| 199 | + createTable(tableName, path) |
| 200 | + } |
| 201 | + |
| 202 | + /** |
| 203 | + * :: Experimental :: |
| 204 | + * Creates a table from the given path and returns the corresponding DataFrame. |
| 205 | + * It will use the default data source configured by spark.sql.sources.default. |
| 206 | + * |
| 207 | + * @since 2.2.0 |
| 208 | + */ |
196 | 209 | @Experimental |
197 | 210 | @InterfaceStability.Evolving |
198 | | - def createExternalTable(tableName: String, path: String): DataFrame |
| 211 | + def createTable(tableName: String, path: String): DataFrame |
199 | 212 |
|
200 | 213 | /** |
201 | | - * :: Experimental :: |
202 | | - * Creates an external table from the given path based on a data source |
203 | | - * and returns the corresponding DataFrame. |
| 214 | + * Creates a table from the given path based on a data source and returns the corresponding |
| 215 | + * DataFrame. |
204 | 216 | * |
205 | 217 | * @since 2.0.0 |
206 | 218 | */ |
| 219 | + @deprecated("use createTable instead.", "2.2.0") |
| 220 | + def createExternalTable(tableName: String, path: String, source: String): DataFrame = { |
| 221 | + createTable(tableName, path, source) |
| 222 | + } |
| 223 | + |
| 224 | + /** |
| 225 | + * :: Experimental :: |
| 226 | + * Creates a table from the given path based on a data source and returns the corresponding |
| 227 | + * DataFrame. |
| 228 | + * |
| 229 | + * @since 2.2.0 |
| 230 | + */ |
207 | 231 | @Experimental |
208 | 232 | @InterfaceStability.Evolving |
209 | | - def createExternalTable(tableName: String, path: String, source: String): DataFrame |
| 233 | + def createTable(tableName: String, path: String, source: String): DataFrame |
210 | 234 |
|
211 | 235 | /** |
212 | | - * :: Experimental :: |
213 | | - * Creates an external table from the given path based on a data source and a set of options. |
| 236 | + * Creates a table from the given path based on a data source and a set of options. |
214 | 237 | * Then, returns the corresponding DataFrame. |
215 | 238 | * |
216 | 239 | * @since 2.0.0 |
217 | 240 | */ |
| 241 | + @deprecated("use createTable instead.", "2.2.0") |
| 242 | + def createExternalTable( |
| 243 | + tableName: String, |
| 244 | + source: String, |
| 245 | + options: java.util.Map[String, String]): DataFrame = { |
| 246 | + createTable(tableName, source, options) |
| 247 | + } |
| 248 | + |
| 249 | + /** |
| 250 | + * :: Experimental :: |
| 251 | + * Creates a table from the given path based on a data source and a set of options. |
| 252 | + * Then, returns the corresponding DataFrame. |
| 253 | + * |
| 254 | + * @since 2.2.0 |
| 255 | + */ |
218 | 256 | @Experimental |
219 | 257 | @InterfaceStability.Evolving |
| 258 | + def createTable( |
| 259 | + tableName: String, |
| 260 | + source: String, |
| 261 | + options: java.util.Map[String, String]): DataFrame = { |
| 262 | + createTable(tableName, source, options.asScala.toMap) |
| 263 | + } |
| 264 | + |
| 265 | + /** |
| 266 | + * (Scala-specific) |
| 267 | + * Creates a table from the given path based on a data source and a set of options. |
| 268 | + * Then, returns the corresponding DataFrame. |
| 269 | + * |
| 270 | + * @since 2.0.0 |
| 271 | + */ |
| 272 | + @deprecated("use createTable instead.", "2.2.0") |
220 | 273 | def createExternalTable( |
221 | 274 | tableName: String, |
222 | 275 | source: String, |
223 | | - options: java.util.Map[String, String]): DataFrame |
| 276 | + options: Map[String, String]): DataFrame = { |
| 277 | + createTable(tableName, source, options) |
| 278 | + } |
224 | 279 |
|
225 | 280 | /** |
226 | 281 | * :: Experimental :: |
227 | 282 | * (Scala-specific) |
228 | | - * Creates an external table from the given path based on a data source and a set of options. |
| 283 | + * Creates a table from the given path based on a data source and a set of options. |
229 | 284 | * Then, returns the corresponding DataFrame. |
230 | 285 | * |
231 | | - * @since 2.0.0 |
| 286 | + * @since 2.2.0 |
232 | 287 | */ |
233 | 288 | @Experimental |
234 | 289 | @InterfaceStability.Evolving |
235 | | - def createExternalTable( |
| 290 | + def createTable( |
236 | 291 | tableName: String, |
237 | 292 | source: String, |
238 | 293 | options: Map[String, String]): DataFrame |
239 | 294 |
|
240 | 295 | /** |
241 | 296 | * :: Experimental :: |
242 | | - * Create an external table from the given path based on a data source, a schema and |
243 | | - * a set of options. Then, returns the corresponding DataFrame. |
| 297 | + * Create a table from the given path based on a data source, a schema and a set of options. |
| 298 | + * Then, returns the corresponding DataFrame. |
244 | 299 | * |
245 | 300 | * @since 2.0.0 |
246 | 301 | */ |
| 302 | + @deprecated("use createTable instead.", "2.2.0") |
| 303 | + def createExternalTable( |
| 304 | + tableName: String, |
| 305 | + source: String, |
| 306 | + schema: StructType, |
| 307 | + options: java.util.Map[String, String]): DataFrame = { |
| 308 | + createTable(tableName, source, schema, options) |
| 309 | + } |
| 310 | + |
| 311 | + /** |
| 312 | + * :: Experimental :: |
| 313 | + * Create a table from the given path based on a data source, a schema and a set of options. |
| 314 | + * Then, returns the corresponding DataFrame. |
| 315 | + * |
| 316 | + * @since 2.2.0 |
| 317 | + */ |
247 | 318 | @Experimental |
248 | 319 | @InterfaceStability.Evolving |
| 320 | + def createTable( |
| 321 | + tableName: String, |
| 322 | + source: String, |
| 323 | + schema: StructType, |
| 324 | + options: java.util.Map[String, String]): DataFrame = { |
| 325 | + createTable(tableName, source, schema, options.asScala.toMap) |
| 326 | + } |
| 327 | + |
| 328 | + /** |
| 329 | + * (Scala-specific) |
| 330 | + * Create a table from the given path based on a data source, a schema and a set of options. |
| 331 | + * Then, returns the corresponding DataFrame. |
| 332 | + * |
| 333 | + * @since 2.0.0 |
| 334 | + */ |
| 335 | + @deprecated("use createTable instead.", "2.2.0") |
249 | 336 | def createExternalTable( |
250 | 337 | tableName: String, |
251 | 338 | source: String, |
252 | 339 | schema: StructType, |
253 | | - options: java.util.Map[String, String]): DataFrame |
| 340 | + options: Map[String, String]): DataFrame = { |
| 341 | + createTable(tableName, source, schema, options) |
| 342 | + } |
254 | 343 |
|
255 | 344 | /** |
256 | 345 | * :: Experimental :: |
257 | 346 | * (Scala-specific) |
258 | | - * Create an external table from the given path based on a data source, a schema and |
259 | | - * a set of options. Then, returns the corresponding DataFrame. |
| 347 | + * Create a table from the given path based on a data source, a schema and a set of options. |
| 348 | + * Then, returns the corresponding DataFrame. |
260 | 349 | * |
261 | | - * @since 2.0.0 |
| 350 | + * @since 2.2.0 |
262 | 351 | */ |
263 | 352 | @Experimental |
264 | 353 | @InterfaceStability.Evolving |
265 | | - def createExternalTable( |
| 354 | + def createTable( |
266 | 355 | tableName: String, |
267 | 356 | source: String, |
268 | 357 | schema: StructType, |
|
0 commit comments