You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/26 20:44:01 UTC

[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #8582: Support conjugates for scalar functions (with early termination) (WIP)

Jackie-Jiang commented on code in PR #8582:
URL: https://github.com/apache/pinot/pull/8582#discussion_r859120220


##########
pinot-common/src/main/java/org/apache/pinot/common/request/context/ExpressionContext.java:
##########
@@ -22,6 +22,7 @@
 import java.util.Set;
 
 
+

Review Comment:
   (minor) Revert this file



##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ComparisonFunctions.java:
##########
@@ -0,0 +1,60 @@
+/**
+ * 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.common.function.scalar;
+
+import org.apache.pinot.spi.annotations.ScalarFunction;
+
+public class ComparisonFunctions {
+
+  private static final double DOUBLE_COMPARISON_TOLERANCE = 1e-7d;
+
+  private ComparisonFunctions() {
+  }
+
+  @ScalarFunction(names = {"gt"})

Review Comment:
   User will mostly likely use the function name within the `FilterKind`, and we should include that in the alias



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/function/InbuiltFunctionEvaluator.java:
##########
@@ -68,17 +67,23 @@ private ExecutableNode planExecution(ExpressionContext expression) {
           childNodes[i] = planExecution(arguments.get(i));
         }
         String functionName = function.getFunctionName();
-        FunctionInfo functionInfo = FunctionRegistry.getFunctionInfo(functionName, numArguments);
-        if (functionInfo == null) {
-          if (FunctionRegistry.containsFunction(functionName)) {
-            throw new IllegalStateException(
-              String.format("Unsupported function: %s with %d parameters", functionName, numArguments));
-          } else {
-            throw new IllegalStateException(
-              String.format("Unsupported function: %s not found", functionName));
-          }
+        switch (functionName) {
+          case "and":
+          case "or":
+            return new ConjugationExecutionNode(functionName, childNodes);

Review Comment:
   Suggest adding 3 execution nodes: `AndExecutionNode`, `OrExecutionNode`, `NotExecutionNode`. IMO no need to add the concept of `ConjugateFunction`



##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/RecordTransformerTest.java:
##########
@@ -178,6 +178,27 @@ public void testSanitationTransformer() {
     }
   }
 
+  @Test
+  public void testLogicalScalarOps() {
+    TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("testTable").build();
+
+    // expression true, filtered
+    GenericRow genericRow = getRecord();
+    tableConfig.setIngestionConfig(
+        new IngestionConfig(null, null, new FilterConfig("and(eq(svInt, 123), lte(svInt, 123))"), null, null));

Review Comment:
   Does `svInt = 123 AND svInt < 123` work? Users usually don't use `eq` or `lte` explicitly.
   Also let's put some filter that can potentially match record to test the behavior



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org