Skip to content

Commit

Permalink
Apply review suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
morazow committed Feb 1, 2021
1 parent ae92af0 commit 4630042
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
7 changes: 3 additions & 4 deletions src/it/scala/com/exasol/cloudetl/BaseIntegrationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ trait BaseIntegrationTest extends AnyFunSuite with BeforeAndAfterAll {
val assembledJarName = getAssembledJarName()

var schema: ExasolSchema = _
var factory: ExasolObjectFactory = _

def startContainers(): Unit = {
exasolContainer.start()
Expand All @@ -38,10 +37,10 @@ trait BaseIntegrationTest extends AnyFunSuite with BeforeAndAfterAll {

def prepareExasolDatabase(schemaName: String): Unit = {
executeStmt(s"DROP SCHEMA IF EXISTS $schemaName CASCADE;")
factory = new ExasolObjectFactory(getConnection())
val factory = new ExasolObjectFactory(getConnection())
schema = factory.createSchema(schemaName)
createDeploymentScripts()
createConnectionObject()
createConnectionObject(factory)
uploadJarToBucket()
}

Expand Down Expand Up @@ -90,7 +89,7 @@ trait BaseIntegrationTest extends AnyFunSuite with BeforeAndAfterAll {
()
}

private[this] def createConnectionObject(): Unit = {
private[this] def createConnectionObject(factory: ExasolObjectFactory): Unit = {
val credentials = s3Container.getDefaultCredentialsProvider().getCredentials()
val awsAccessKey = credentials.getAWSAccessKeyId()
val awsSecretKey = credentials.getAWSSecretKey()
Expand Down
60 changes: 41 additions & 19 deletions src/it/scala/com/exasol/cloudetl/DataImporterIT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ import org.scalatest.funsuite.AnyFunSuite

class DataImporterIT extends BaseIntegrationTest {

val INT_MIN = -2147483648
val INT_MAX = 2147483647
val LONG_MIN = -9223372036854775808L
val LONG_MAX = 9223372036854775807L
val schemaName = "DATA_SCHEMA"
val bucketName: String = "databucket"
var conf: Configuration = _
Expand Down Expand Up @@ -92,13 +96,13 @@ class DataImporterIT extends BaseIntegrationTest {
}

test("imports int") {
AvroChecker(getBasicSchema("\"int\""), "DECIMAL(9,0)")
.withInputValues(List(1, 13, 5))
AvroChecker(getBasicSchema("\"int\""), "DECIMAL(10,0)")
.withInputValues(List(INT_MIN, 13, INT_MAX))
.assertResultSet(
table()
.row(java.lang.Integer.valueOf(1))
.row(java.lang.Integer.valueOf(INT_MIN))
.row(java.lang.Integer.valueOf(13))
.row(java.lang.Integer.valueOf(5))
.row(java.lang.Integer.valueOf(INT_MAX))
.matches(NO_JAVA_TYPE_CHECK)
)
}
Expand All @@ -116,12 +120,13 @@ class DataImporterIT extends BaseIntegrationTest {
}

test("imports long") {
AvroChecker(getBasicSchema("\"long\""), "DECIMAL(18,0)")
.withInputValues(List(7L, 77L))
AvroChecker(getBasicSchema("\"long\""), "DECIMAL(19,0)")
.withInputValues(List(LONG_MIN, 77L, LONG_MAX))
.assertResultSet(
table()
.row(java.lang.Long.valueOf(7))
.row(java.lang.Long.valueOf(LONG_MIN))
.row(java.lang.Long.valueOf(77))
.row(java.lang.Long.valueOf(LONG_MAX))
.matches(NO_JAVA_TYPE_CHECK)
)
}
Expand Down Expand Up @@ -404,15 +409,29 @@ class DataImporterIT extends BaseIntegrationTest {
}

test("imports int") {
OrcChecker("struct<f:int>", "DECIMAL(9,0)")
.withInputValues(List(999, null))
.assertResultSet(table().row(java.lang.Integer.valueOf(999)).row(null).matches())
OrcChecker("struct<f:int>", "DECIMAL(10,0)")
.withInputValues(List(INT_MIN, 999, null, INT_MAX))
.assertResultSet(
table()
.row(java.lang.Integer.valueOf(INT_MIN))
.row(java.lang.Integer.valueOf(999))
.row(null)
.row(java.lang.Integer.valueOf(INT_MAX))
.matches(NO_JAVA_TYPE_CHECK)
)
}

test("imports long") {
OrcChecker("struct<f:bigint>", "DECIMAL(18,0)")
.withInputValues(List(1234L, null))
.assertResultSet(table().row(java.lang.Long.valueOf(1234)).row(null).matches())
OrcChecker("struct<f:bigint>", "DECIMAL(19,0)")
.withInputValues(List(LONG_MIN, 1234L, null, LONG_MAX))
.assertResultSet(
table()
.row(java.lang.Long.valueOf(LONG_MIN))
.row(java.lang.Long.valueOf(1234))
.row(null)
.row(java.lang.Long.valueOf(LONG_MAX))
.matches(NO_JAVA_TYPE_CHECK)
)
}

test("imports float") {
Expand Down Expand Up @@ -604,14 +623,15 @@ class DataImporterIT extends BaseIntegrationTest {
}

test("imports int32") {
ParquetChecker("optional int32 column;", "DECIMAL(9,0)")
.withInputValues[Any](List(1, 666, null))
ParquetChecker("optional int32 column;", "DECIMAL(10,0)")
.withInputValues[Any](List(INT_MIN, 666, null, INT_MAX))
.assertResultSet(
table()
.row(java.lang.Integer.valueOf(1))
.row(java.lang.Integer.valueOf(INT_MIN))
.row(java.lang.Integer.valueOf(666))
.row(null)
.matches()
.row(java.lang.Integer.valueOf(INT_MAX))
.matches(NO_JAVA_TYPE_CHECK)
)
}

Expand Down Expand Up @@ -643,12 +663,14 @@ class DataImporterIT extends BaseIntegrationTest {
}

test("imports int64") {
ParquetChecker("optional int64 column;", "DECIMAL(18,0)")
.withInputValues[Any](List(999L, null))
ParquetChecker("optional int64 column;", "DECIMAL(19,0)")
.withInputValues[Any](List(LONG_MIN, 999L, null, LONG_MAX))
.assertResultSet(
table()
.row(java.lang.Long.valueOf(LONG_MIN))
.row(java.lang.Long.valueOf(999))
.row(null)
.row(java.lang.Long.valueOf(LONG_MAX))
.matches(NO_JAVA_TYPE_CHECK)
)
}
Expand Down

0 comments on commit 4630042

Please sign in to comment.