Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonwang-db committed Nov 26, 2024
1 parent d9757b5 commit c3ef33d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,6 @@ object DataSource extends Logging {
throw e
}
}
case _ :: Nil if isUserDefinedDataSource =>
// There was DSv1 or DSv2 loaded, but the same name source was found
// in user defined data source.
throw QueryCompilationErrors.foundMultipleDataSources(provider)
case head :: Nil =>
head.getClass
case sources =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ object DataSourceManager extends Logging {

private def initialStaticDataSourceBuilders: Map[String, UserDefinedPythonDataSource] = {
if (shouldLoadPythonDataSources) this.synchronized {
logInfo("Loading static Python Data Sources.")
if (dataSourceBuilders.isEmpty) {
val maybeResult = try {
Some(UserDefinedPythonDataSource.lookupAllDataSourcesInPython())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ class PythonDataSourceSuite extends PythonDataSourceSuiteBase {
checkAnswer(df, Seq(Row(0, 0), Row(0, 1), Row(1, 0), Row(1, 1), Row(2, 0), Row(2, 1)))
}

test("SPARK-50426: should not trigger static Python data source lookup") {
assume(shouldTestPandasUDFs)
val testAppender = new LogAppender("Python data source lookup")
// Using builtin and Java data sources should not trigger a static
// Python data source lookup
withLogAppender(testAppender) {
spark.read.format("org.apache.spark.sql.test").load()
spark.range(3).write.mode("overwrite").format("noop").save()
}
assert(!testAppender.loggingEvents
.exists(msg => msg.getMessage.getFormattedMessage.contains(
"Loading static Python Data Sources.")))
// Now trigger a Python data source lookup
withLogAppender(testAppender) {
spark.read.format(staticSourceName).load()
}
assert(testAppender.loggingEvents
.exists(msg => msg.getMessage.getFormattedMessage.contains(
"Loading static Python Data Sources.")))
}

test("simple data source") {
assume(shouldTestPandasUDFs)
val dataSourceScript =
Expand Down

0 comments on commit c3ef33d

Please sign in to comment.