HyukjinKwon closed pull request #23479: [SPARK-26556][SQL]Add custom provider
for thrid party connector
URL: https://github.com/apache/spark/pull/23479
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala
index fefff68c4ba8b..77d8f46c51de7 100644
---
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala
+++
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala
@@ -621,7 +621,7 @@ object DataSource extends Logging {
"org.apache.spark.sql.hive.orc.OrcFileFormat"
case "com.databricks.spark.avro" if
conf.replaceDatabricksSparkAvroEnabled =>
"org.apache.spark.sql.avro.AvroFileFormat"
- case name => name
+ case name => conf.getConfString(s"spark.sql.source.provider.$name", name)
}
val provider2 = s"$provider1.DefaultSource"
val loader = Utils.getContextOrSparkClassLoader
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/sources/CustomProviderSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/sources/CustomProviderSuite.scala
new file mode 100644
index 0000000000000..7fa081b4a83da
--- /dev/null
+++
b/sql/core/src/test/scala/org/apache/spark/sql/sources/CustomProviderSuite.scala
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.sources
+
+import org.apache.spark.SparkFunSuite
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.execution.datasources.DataSource
+import org.apache.spark.sql.test.SharedSQLContext
+
+class CustomProviderSuite extends SparkFunSuite with SharedSQLContext {
+
+ override protected def sparkConf = {
+ val conf = super.sparkConf
+ conf.set("spark.sql.source.provider.fake1",
"org.apache.spark.sql.sources.FakeSourceOne")
+ }
+
+ private def getProvidingClass(name: String): Class[_] =
+ DataSource(
+ sparkSession = spark,
+ className = name
+ ).providingClass
+
+ test("fake source with custom provider") {
+ assert(
+ getProvidingClass("fake1") ===
+ classOf[org.apache.spark.sql.sources.FakeSourceOne])
+ }
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]