HyukjinKwon commented on code in PR #44507: URL: https://github.com/apache/spark/pull/44507#discussion_r1444175715
########## 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: I am fine with this for now but should probably make sure ^ change happen before Spark 4.0. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org