Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/7802#discussion_r36497720
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/sources/DDLSourceLoadSuite.scala
---
@@ -0,0 +1,79 @@
+/*
+* 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.sql.SQLContext
+import org.apache.spark.sql.types.{StringType, StructField, StructType}
+
+class FakeSourceOne extends RelationProvider with DataSourceRegister {
+
+ def format(): String = "Fluet da Bomb"
+
+ override def createRelation(cont: SQLContext, param: Map[String,
String]): BaseRelation =
+ new BaseRelation {
+ override def sqlContext: SQLContext = cont
+
+ override def schema: StructType =
+ StructType(Seq(StructField("stringType", StringType, nullable =
false)))
+ }
+}
+
+class FakeSourceTwo extends RelationProvider with DataSourceRegister {
+
+ def format(): String = "Fluet da Bomb"
+
+ override def createRelation(cont: SQLContext, param: Map[String,
String]): BaseRelation =
+ new BaseRelation {
+ override def sqlContext: SQLContext = cont
+
+ override def schema: StructType =
+ StructType(Seq(StructField("stringType", StringType, nullable =
false)))
+ }
+}
+
+class FakeSourceThree extends RelationProvider with DataSourceRegister {
+
+ def format(): String = "gathering quorum"
+
+ override def createRelation(cont: SQLContext, param: Map[String,
String]): BaseRelation =
+ new BaseRelation {
+ override def sqlContext: SQLContext = cont
+
+ override def schema: StructType =
+ StructType(Seq(StructField("stringType", StringType, nullable =
false)))
+ }
+}
+// please note that the META-INF/services had to be modified for the test
directory for this to work
+class DDLSourceLoadSuite extends DataSourceTest {
+
+ test("data sources with the same name") {
+ intercept[RuntimeException] {
+ caseInsensitiveContext.read.format("Fluet da Bomb").load()
+ }
+ }
+
+ test("load data source from format alias") {
+ caseInsensitiveContext.read.format("gathering quorum").load().schema ==
+ StructType(Seq(StructField("stringType", StringType, nullable =
false)))
+ }
+
+ test("specify full classname with duplicate formats") {
+
caseInsensitiveContext.read.format("org.apache.spark.sql.sources.FakeSourceOne")
+ .load().schema == StructType(Seq(StructField("stringType",
StringType, nullable = false)))
+ }
--- End diff --
Maybe we should add a test for fail loading the orc with `SQLContext`, and
also with `HiveContext`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]