walterddr commented on code in PR #9330:
URL: https://github.com/apache/pinot/pull/9330#discussion_r962081506


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/NotOperatorTransformFunction.java:
##########
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.transform.function;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.common.function.TransformFunctionType;
+import org.apache.pinot.core.operator.blocks.ProjectionBlock;
+import org.apache.pinot.core.operator.transform.TransformResultMetadata;
+import org.apache.pinot.segment.spi.datasource.DataSource;
+import org.apache.pinot.spi.utils.ArrayCopyUtils;
+
+
+/**
+ * The <code>Not</code> extends implement the Not operator.
+ *
+ * The results are in boolean format and stored as an integer array with 1 
represents true and 0 represents false.
+ * It takes a single argument and negates it and the argument has to be a 
boolean/integer.
+ *
+ * Expected result:
+ * Not (1 = 1) | 0
+ * Not 1       | 0
+ *
+ * SQL Syntax:
+ *    Not <Boolean Expression>
+ *
+ * Sample Usage:
+ *    Not(booleanA)

Review Comment:
   sample usage and sample syntax is not the same here. `(` and `)` should be 
optional. 



##########
pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java:
##########
@@ -65,6 +65,7 @@ public enum TransformFunctionType {
 
   AND("and"),
   OR("or"),
+  NOT("not"),

Review Comment:
   let's add a comment indicating `NOT_EQUAL` and `NOT_IN` are not covered by 
this branch



##########
pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/NotOperatorTransformFunctionTest.java:
##########
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.operator.transform.function;
+
+import org.apache.pinot.common.request.context.ExpressionContext;
+import org.apache.pinot.common.request.context.RequestContextUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class NotOperatorTransformFunctionTest extends 
BaseTransformFunctionTest {
+  // Test not true returns false.
+  @Test
+  public void testNotTrueOperatorTransformFunction() {
+    ExpressionContext expr =
+        RequestContextUtils.getExpression(String.format("Not (%d = %d)", 
_intSVValues[0], _intSVValues[0]));
+    TransformFunction func = TransformFunctionFactory.get(expr, 
_dataSourceMap);
+    Assert.assertEquals(func.getName(), "not");
+    int[] notTrueExpectedIntValues = new int[NUM_ROWS];
+    for (int i = 0; i < NUM_ROWS; i++) {
+      notTrueExpectedIntValues[i] = 0;
+    }
+    testTransformFunction(func, notTrueExpectedIntValues);
+  }
+
+  // Test not false returns true.
+  @Test
+  public void testNotFalseOperatorTransformFunction() {
+    ExpressionContext expr =
+        RequestContextUtils.getExpression(String.format("Not (%d != %d)", 
_intSVValues[0], _intSVValues[0]));
+    TransformFunction func = TransformFunctionFactory.get(expr, 
_dataSourceMap);
+    Assert.assertEquals(func.getName(), "not");
+    int[] notTrueExpectedIntValues = new int[NUM_ROWS];
+    for (int i = 0; i < NUM_ROWS; i++) {
+      notTrueExpectedIntValues[i] = 1;
+    }
+    testTransformFunction(func, notTrueExpectedIntValues);
+  }

Review Comment:
   can you also add a test for values?
   
   e.g. 
   ```
           RequestContextUtils.getExpression(String.format("Not (%s != %d)", 
INT_SV_COLUMN, _intSVValues[0]));
   ```
   and see if it works (as they should because the expression result in a 
binary result



-- 
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