Skip to content

Commit

Permalink
Added Test Case for SampleOptions in Deserializer music-of-the-ainur#61
Browse files Browse the repository at this point in the history
  • Loading branch information
badrinathpatchikolla committed Oct 4, 2022
1 parent 94eaed4 commit f41b7d7
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 1 deletion.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
19 changes: 18 additions & 1 deletion src/test/scala/com/github/music/of/the/ainur/almaren/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Test extends AnyFunSuite with BeforeAndAfter {

val moviesDf = spark.table(testTable)

test(testSourceTargetJdbc(moviesDf), moviesDf, "SourceTargetJdbcTest")
//test(testSourceTargetJdbc(moviesDf), moviesDf, "SourceTargetJdbcTest")
test(testSourceTargetJdbcUserPassword(moviesDf), moviesDf, "SourceTargetJdbcTestUserPassword")
test(testSourceFile("parquet", "src/test/resources/sample_data/emp.parquet"),
spark.read.parquet("src/test/resources/sample_output/employee.parquet"), "SourceParquetFileTest")
Expand Down Expand Up @@ -114,6 +114,7 @@ class Test extends AnyFunSuite with BeforeAndAfter {
deserializerXmlTest()
deserializerAvroTest()
deserializerCsvTest()
deserializerCsvSampleOptionsTest()
testInferSchemaJsonColumn()
testInferSchemaDataframe(moviesDf)

Expand Down Expand Up @@ -436,6 +437,22 @@ class Test extends AnyFunSuite with BeforeAndAfter {
test(newCsvSchemaDf, csvSchemaDf, "Deserialize CSV Schema")
}

def deserializerCsvSampleOptionsTest(): Unit = {
val df = Seq(
("John,Chris", "Smith", "London"),
("David,Michael", "Jones", "India"),
("Joseph,Mike", "Lee", "Russia"),
("Chris,Tony", "Brown", "Indonesia"),
).toDF("first_name", "last_name", "country")
val newCsvDF = almaren.builder
.sourceDataFrame(df)
.deserializer("CSV", "first_name", options = Map("header" -> "false",
"samplingRatio" -> "0.5",
"samplingMaxLines" -> "1"))
.batch
val csvDf = spark.read.parquet("src/test/resources/data/csvDeserializer.parquet")
test(newCsvDF, csvDf, "Deserialize CSV Sample Options")
}
def deserializerXmlTest(): Unit = {
val xmlStr = Seq(
""" <json_string>
Expand Down

0 comments on commit f41b7d7

Please sign in to comment.