Skip to content

Instantly share code, notes, and snippets.

@sakhtar-git
Created March 29, 2023 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakhtar-git/d8ca1153b27da2b6fdde97dfe606685c to your computer and use it in GitHub Desktop.
Save sakhtar-git/d8ca1153b27da2b6fdde97dfe606685c to your computer and use it in GitHub Desktop.
import org.apache.spark.sql.types.{IntegerType, StringType, StructField, StructType}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
class MyDataFrameTest extends AnyFunSuite with Matchers {
test("test schema of myDataFrame") {
val myDataFrame = Seq(
("John", 25),
("Jane", 30),
("Bob", 40)
).toDF("name", "age")
val expectedSchema = StructType(Seq(
StructField("name", StringType, nullable = true),
StructField("age", IntegerType, nullable = true)
))
myDataFrame.schema shouldEqual expectedSchema
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment