Skip to content

Commit

Permalink
modifed test to ensure order of transformers.
Browse files Browse the repository at this point in the history
  • Loading branch information
aishikbh authored and snleee committed Nov 24, 2023
1 parent 06e91c1 commit 05be5cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public GenericRow transform(GenericRow record) {
negativeZeroNanSanitizedValues.add(nanTransformedValue);
}
}
record.putValue(element,negativeZeroNanSanitizedValues.toArray());
record.putValue(element, negativeZeroNanSanitizedValues.toArray());
} else {
// Single-valued column.
Object zeroTransformedValue = transformNegativeZero(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ public void testOrderForTransformers() {
Schema schema = new Schema.SchemaBuilder().addSingleValueDimension("svInt", DataType.INT)
.addSingleValueDimension("svDouble", DataType.DOUBLE)
.addSingleValueDimension("expressionTestColumn", DataType.INT)
.addSingleValueDimension("svNaN", DataType.FLOAT).addMultiValueDimension("mvNaN",DataType.FLOAT)
.addSingleValueDimension("svNaN", DataType.FLOAT).addMultiValueDimension("mvNaN", DataType.FLOAT)
.addSingleValueDimension("emptyDimensionForNullValueTransformer", DataType.FLOAT)
.addSingleValueDimension("svStringWithNullCharacters", DataType.STRING)
.addSingleValueDimension("svStringNull", DataType.STRING)
.addSingleValueDimension("indexableExtras", DataType.JSON)
.addDateTime("timeCol", DataType.TIMESTAMP, "1:MILLISECONDS:TIMESTAMP", "1:MILLISECONDS").build();

Expand All @@ -326,7 +326,7 @@ public void testOrderForTransformers() {
List<RecordTransformer> currentListOfTransformers =
CompositeTransformer.getDefaultTransformers(tableConfig, schema);

// Create a list of transformers to compare.
// Create a list of transformers in the original order to compare.
List<RecordTransformer> expectedListOfTransformers =
List.of(new ExpressionTransformer(tableConfig, schema), new FilterTransformer(tableConfig),
new SchemaConformingTransformer(tableConfig, schema), new DataTypeTransformer(tableConfig, schema),
Expand All @@ -352,14 +352,15 @@ public void testOrderForTransformers() {

// Data for SpecialValue Transformer.
record.putValue("svNaN", Float.NaN);
record.putValue("mvNaN",new Float[]{1.0f,Float.NaN,2.0f});
record.putValue("mvNaN", new Float[]{1.0f, Float.NaN, 2.0f});

// Data for sanitization transformer.
record.putValue("svStringWithNullCharacters", "1\0002\0003");
record.putValue("svStringNull", null);

for (int i = 0; i < NUMBER_OF_TRANSFORMERS; i++) {
GenericRow copyRecord = record.copy();
GenericRow currentRecord = currentListOfTransformers.get(i).transform(record);
GenericRow expectedRecord = expectedListOfTransformers.get(i).transform(record);
GenericRow expectedRecord = expectedListOfTransformers.get(i).transform(copyRecord);
assertEquals(currentRecord, expectedRecord);
record = expectedRecord;
}
Expand Down Expand Up @@ -652,7 +653,8 @@ record = transformer.transform(record);
new Float[]{0.0f, 2.0f});
assertEquals(record.getValue("mvDoubleNaN"),
new Double[]{0.0d, 2.0d});
assertEquals(new ArrayList<>(record.getNullValueFields()), new ArrayList<>(Arrays.asList("svFloatNaN","svDoubleNaN")));
assertEquals(new ArrayList<>(record.getNullValueFields()),
new ArrayList<>(Arrays.asList("svFloatNaN", "svDoubleNaN")));
}

// Test empty record
Expand Down

0 comments on commit 05be5cf

Please sign in to comment.