Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
while here, delete the "recordkey field not specified" test for
ComplexKeyGenerator
  • Loading branch information
qjqqyy committed May 7, 2022
1 parent 3631a4c commit 32733bd
Showing 1 changed file with 8 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,50 +277,19 @@ class TestDataSourceDefaults {
assertEquals("field1/name1", keyGen.getPartitionPath(baseRow))

// partition path field not specified
try {
val props = new TypedProperties()
props.setProperty(DataSourceWriteOptions.RECORDKEY_FIELD.key, "field1")
new ComplexKeyGenerator(props).getKey(baseRecord)
fail("Should have errored out")
} catch {
case e: IllegalArgumentException =>
// do nothing
}

// partition path field not specified using Row
try {
keyGen = {
val props = new TypedProperties()
props.setProperty(DataSourceWriteOptions.RECORDKEY_FIELD.key, "field1")
val keyGen = new ComplexKeyGenerator(props)
keyGen.getRecordKey(baseRow)
fail("Should have errored out")
} catch {
case e: IllegalArgumentException =>
// do nothing
new ComplexKeyGenerator(props)
}

// recordkey field not specified
try {
val props = new TypedProperties()
props.setProperty(DataSourceWriteOptions.PARTITIONPATH_FIELD.key, "partitionField")
new ComplexKeyGenerator(props).getKey(baseRecord)
fail("Should have errored out")
} catch {
case e: IllegalArgumentException =>
// do nothing
}
val nonPartitionedHk = keyGen.getKey(baseRecord)
assertEquals("field1:field1", nonPartitionedHk.getRecordKey)
assertEquals("", nonPartitionedHk.getPartitionPath)

// recordkey field not specified
try {
val props = new TypedProperties()
props.setProperty(DataSourceWriteOptions.PARTITIONPATH_FIELD.key, "partitionField")
val keyGen = new ComplexKeyGenerator(props)
keyGen.getPartitionPath(baseRow)
fail("Should have errored out")
} catch {
case e: IllegalArgumentException =>
// do nothing
}
// partition path field not specified using Row
assertEquals("field1:field1", keyGen.getRecordKey(baseRow))
assertEquals("", keyGen.getPartitionPath(baseRow))

// nested field as record key and partition path
keyGen = new ComplexKeyGenerator(getKeyConfig("testNestedRecord.userId,testNestedRecord.isAdmin", "testNestedRecord.userId,testNestedRecord.isAdmin", "false"))
Expand Down

0 comments on commit 32733bd

Please sign in to comment.