From 05be5cfd9ade65d2785a412f6b0692f7ba0c0eb6 Mon Sep 17 00:00:00 2001 From: Aishik Date: Thu, 23 Nov 2023 23:14:26 +0530 Subject: [PATCH] modifed test to ensure order of transformers. --- .../SpecialValueTransformer.java | 2 +- .../recordtransformer/RecordTransformerTest.java | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/recordtransformer/SpecialValueTransformer.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/recordtransformer/SpecialValueTransformer.java index 26df94933a8e..33838031942d 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/recordtransformer/SpecialValueTransformer.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/recordtransformer/SpecialValueTransformer.java @@ -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); diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/RecordTransformerTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/RecordTransformerTest.java index 2685f8b6da42..410fa195646c 100644 --- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/RecordTransformerTest.java +++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/RecordTransformerTest.java @@ -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(); @@ -326,7 +326,7 @@ public void testOrderForTransformers() { List currentListOfTransformers = CompositeTransformer.getDefaultTransformers(tableConfig, schema); - // Create a list of transformers to compare. + // Create a list of transformers in the original order to compare. List expectedListOfTransformers = List.of(new ExpressionTransformer(tableConfig, schema), new FilterTransformer(tableConfig), new SchemaConformingTransformer(tableConfig, schema), new DataTypeTransformer(tableConfig, schema), @@ -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; } @@ -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