HyukjinKwon commented on code in PR #44507:
URL: https://github.com/apache/spark/pull/44507#discussion_r1436987063
##########
sql/core/src/main/scala/org/apache/spark/sql/DataSourceRegistration.scala:
##########
@@ -28,7 +31,7 @@ import
org.apache.spark.sql.execution.python.UserDefinedPythonDataSource
*/
@Evolving
private[sql] class DataSourceRegistration private[sql] (dataSourceManager:
DataSourceManager)
- extends Logging {
+ extends Logging with SQLConfHelper {
Review Comment:
Maybe just call `SQLConf.get` for `conf`.
##########
sql/core/src/main/scala/org/apache/spark/sql/DataSourceRegistration.scala:
##########
@@ -43,6 +46,33 @@ private[sql] class DataSourceRegistration private[sql]
(dataSourceManager: DataS
| pythonExec: ${dataSource.dataSourceCls.pythonExec}
""".stripMargin)
+ checkDataSourceExists(name)
+
dataSourceManager.registerDataSource(name, dataSource)
}
+
+ /**
+ * Checks if the specified data source exists.
+ *
+ * This method allows for user-defined data sources to be registered even if
they
+ * have the same name as an existing data source in the registry. However,
if the
+ * data source can be successfully loaded and is not a user-defined one, an
error
+ * is thrown to prevent lookup errors with built-in or Scala/Java data
sources.
+ */
+ private def checkDataSourceExists(name: String): Unit = {
+ // Allow re-registration of user-defined data sources.
+ if (dataSourceManager.dataSourceExists(name)) return
+
+ try {
+ DataSource.lookupDataSource(name, conf)
Review Comment:
Maybe just call `SQLConf.get` for `conf`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]