Skip to content

Commit 03dc0f6

Browse files
committed
Different approach for SPARK-20590
1 parent 58518d0 commit 03dc0f6

File tree

1 file changed

+11
-1
lines changed
  • sql/core/src/main/scala/org/apache/spark/sql/execution/datasources

1 file changed

+11
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ case class DataSource(
481481
}
482482
}
483483

484-
object DataSource {
484+
object DataSource extends Logging {
485485

486486
/** A map to maintain backward compatibility in case we move data sources around. */
487487
private val backwardCompatibilityMap: Map[String, String] = {
@@ -569,6 +569,16 @@ object DataSource {
569569
case head :: Nil =>
570570
// there is exactly one registered alias
571571
head.getClass
572+
case sources if sources.map(_.getClass.getName).exists(_.startsWith("org.apache.spark")) =>
573+
// There are multiple registered aliases for the input. If there is "org.apache.spark"
574+
// package in the prefix, we use it considering it is an internal datasource within Spark.
575+
val internalSource =
576+
sources.find(_.getClass.getName.startsWith("org.apache.spark")).head
577+
logWarning(s"Multiple sources found for $provider1 " +
578+
s"(${sources.map(_.getClass.getName).mkString(", ")}), " +
579+
"please specify the fully qualified class name. " +
580+
s"Using the internal datasource (${internalSource.getClass.getName}).")
581+
internalSource.getClass
572582
case sources =>
573583
// There are multiple registered aliases for the input
574584
sys.error(s"Multiple sources found for $provider1 " +

0 commit comments

Comments
 (0)