shenyu0127 commented on code in PR #11721:
URL: https://github.com/apache/pinot/pull/11721#discussion_r1342250285


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunction.java:
##########
@@ -228,7 +229,8 @@ public TransformResultMetadata getResultMetadata() {
     return _resultMetadata;
   }
 
-  private boolean isNullLiteralTransformation(TransformFunction function) {
+  @VisibleForTesting

Review Comment:
   We want to test private methods via public APIs.
   
   https://abseil.io/resources/swe-book/html/ch12.html, section "Test via 
Public APIs".



##########
pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunctionTest.java:
##########
@@ -195,6 +196,75 @@ public void testCaseTransformFunctionWithStringResults() {
           getExpectedStringResults(STRING_SV_COLUMN, functionType));
     }
   }
+  @Test

Review Comment:
   Need one space between unit tests.



##########
pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CaseTransformFunctionTest.java:
##########
@@ -195,6 +196,75 @@ public void testCaseTransformFunctionWithStringResults() {
           getExpectedStringResults(STRING_SV_COLUMN, functionType));
     }
   }
+  @Test
+  public void testCaseTransformationWithNullColumn() {
+    ExpressionContext expression =
+        RequestContextUtils.getExpression(
+            String.format("CASE WHEN %s IS NULL THEN 'aaa' ELSE 'bbb' END", 
STRING_ALPHANUM_NULL_SV_COLUMN));
+    TransformFunction transformFunction = 
TransformFunctionFactory.getNullHandlingEnabled(expression, _dataSourceMap);
+    Assert.assertTrue(transformFunction instanceof CaseTransformFunction);
+    Assert.assertEquals(transformFunction.getName(), "case");
+    Assert.assertEquals(transformFunction.getResultMetadata().getDataType(), 
DataType.STRING);
+
+    CaseTransformFunction castTransformFunction = (CaseTransformFunction) 
transformFunction;
+    
Assert.assertFalse(castTransformFunction.isNullLiteralTransformation(castTransformFunction._arguments.get(2)));
+
+    String[] expectedValues = new String[NUM_ROWS];
+    for (int i = 0; i < NUM_ROWS; i++) {
+      if (isNullRow(i)) {
+        expectedValues[i] = "aaa";
+      } else {
+        expectedValues[i] = "bbb";
+      }
+    }
+    testTransformFunction(transformFunction, expectedValues);

Review Comment:
   Use `testTransformFunctionWithNull` and pass an empty `RoaringBitmap`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to