Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifying the usage #176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ object SparkBigQueryOptions {
: SparkBigQueryOptions = {
val normalizedAllConf = normalizeAllConf(allConf)

val tableParam = getRequiredOption(parameters, "table")
val tableParam = getRequiredOption(parameters, "table", () => getOption(parameters, "path"))
val datasetParam = getOption(parameters, "dataset")
val projectParam = getOption(parameters, "project")
.orElse(Option(hadoopConf.get(GcsConfigProjectIdProperty)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class SparkBigQueryEndToEndITSuite extends FunSuite
spark.read.format("bigquery").option("table", SHAKESPEARE_TABLE).load()
}

testShakespeare("simplified api") {
spark.read.format("bigquery").load(SHAKESPEARE_TABLE)
}

testsWithReadInFormat("avro")
testsWithReadInFormat("arrow")

Expand Down Expand Up @@ -344,7 +348,7 @@ class SparkBigQueryEndToEndITSuite extends FunSuite

/** Generate a test to verify that the given DataFrame is equal to a known result. */
def testShakespeare(description: String)(df: => DataFrame): Unit = {
test(description) {
test(s"read using $description") {
val youCannotImportVars = spark
import youCannotImportVars.implicits._
assert(SHAKESPEARE_TABLE_SCHEMA == df.schema)
Expand Down Expand Up @@ -456,6 +460,14 @@ class SparkBigQueryEndToEndITSuite extends FunSuite
initialDataValuesExist shouldBe true
}

test("write to bq - simplified api") {
initialData.write.format("bigquery")
.option("temporaryGcsBucket", temporaryGcsBucket)
.save(fullTableName)
testTableNumberOfRows shouldBe 2
initialDataValuesExist shouldBe true
}

test("write to bq - unsupported format") {
assertThrows[IllegalArgumentException] {
writeToBigQuery(initialData, SaveMode.ErrorIfExists, "something else")
Expand Down