Skip to content

Commit

Permalink
Testing output to Random folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
angelcervera committed Oct 24, 2020
1 parent ab684ec commit ce85e5c
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,25 @@

package com.acervera.osm4scala.spark

import java.io.File

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.{DataFrame, Row, SaveMode, SparkSession, functions => fn}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

import scala.util.Random

class OsmPbfFormatSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll {

def withTemporalFolder(testCode: File => Any): Unit =
testCode(
new File(
s"target/test_outs/${this.getClass().getCanonicalName()}/${Random.alphanumeric.take(10).mkString.toUpperCase()}"
)
)

val cores = 4
val madridPath = "core/src/test/resources/com/acervera/osm4scala/Madrid.bbbike.osm.pbf"
val monacoPath = "core/src/test/resources/com/acervera/osm4scala/monaco-latest.osm.pbf"
Expand Down Expand Up @@ -115,19 +126,19 @@ class OsmPbfFormatSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll

}

"export to other formats" in {
"export to other formats" in withTemporalFolder { tmpFolder =>
val threeExamples = loadOsmPbf(madridPath)
.filter("id == 55799 || id == 3996192 || id == 171946")
.orderBy("id")

threeExamples.write
.mode(SaveMode.Overwrite)
.format("orc")
.save("target/madrid/three")
.save(s"${tmpFolder}/madrid/three")

val readFromOrc = sqlContext.read
.format("orc")
.load("target/madrid/three")
.load(s"${tmpFolder}/madrid/three")
.orderBy("id")
.collect()

Expand Down

0 comments on commit ce85e5c

Please sign in to comment.