Skip to content

Commit

Permalink
Add a test to check if the original schema doesn't have metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueshin committed Feb 12, 2018
1 parent 6efd5d1 commit ba2062e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1168,4 +1168,26 @@ class JDBCSuite extends SparkFunSuite
val df3 = sql("SELECT * FROM test_sessionInitStatement")
assert(df3.collect() === Array(Row(21519, 1234)))
}

test("jdbc data source shouldn't have metadata in its schema") {
val schema = StructType(Seq(
StructField("NAME", StringType, true), StructField("THEID", IntegerType, true)))

val df = spark.read.format("jdbc")
.option("Url", urlWithUserAndPass)
.option("DbTaBle", "TEST.PEOPLE")
.load()
assert(df.schema === schema)

withTempView("people_view") {
sql(
s"""
|CREATE TEMPORARY VIEW people_view
|USING org.apache.spark.sql.jdbc
|OPTIONS (uRl '$url', DbTaBlE 'TEST.PEOPLE', User 'testUser', PassWord 'testPass')
""".stripMargin.replaceAll("\n", " "))

assert(sql("select * from people_view").schema === schema)
}
}
}

0 comments on commit ba2062e

Please sign in to comment.