Jackie-Jiang commented on code in PR #8582: URL: https://github.com/apache/pinot/pull/8582#discussion_r861405251
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/function/InbuiltFunctionEvaluator.java: ########## @@ -106,6 +117,84 @@ private interface ExecutableNode { Object execute(Object[] values); } + private static class NotExecutionNode implements ExecutableNode { + private final ExecutableNode _argumentNode; + + NotExecutionNode(ExecutableNode argumentNode) { + _argumentNode = argumentNode; + } + + @Override + public Object execute(GenericRow row) { + return !((Boolean) (_argumentNode.execute(row))); + } + + @Override + public Object execute(Object[] values) { + return !((Boolean) (_argumentNode.execute(values))); + } + } + + private static class OrExecutionNode implements ExecutableNode { + private final ExecutableNode[] _argumentNodes; + + OrExecutionNode(ExecutableNode[] argumentNodes) { + _argumentNodes = argumentNodes; + } + + @Override + public Object execute(GenericRow row) { + for (ExecutableNode executableNode :_argumentNodes) { + Boolean res = (Boolean) (executableNode.execute(row)); Review Comment: (nit) Redundant parenthesis, same for others ```suggestion Boolean res = (Boolean) executableNode.execute(row); ``` ########## pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ObjectFunctions.java: ########## @@ -0,0 +1,37 @@ +/** + * 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 ObjectFunctions { + private ObjectFunctions() { + } + + @ScalarFunction(names = {"IS_NULL"}) Review Comment: These 2 methods need to be annotated with `nullableParameters = true` ########## pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ObjectFunctions.java: ########## @@ -0,0 +1,37 @@ +/** + * 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 ObjectFunctions { + private ObjectFunctions() { + } + + @ScalarFunction(names = {"IS_NULL"}) Review Comment: We don't need to annotate the `names` because it matches the method name in the canonical format ########## pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ComparisonFunctions.java: ########## @@ -0,0 +1,65 @@ +/** + * 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 = {"GREATER_THAN", "gt"}) Review Comment: I wonder if users will use `gt` instead of `>`, and IIRC `gt` is not standard SQL syntax. We may just make the method name match the filter kind in camel case (they will be canonicalized to the same name) ########## pinot-segment-local/src/test/java/org/apache/pinot/segment/local/recordtransformer/RecordTransformerTest.java: ########## @@ -178,6 +178,29 @@ 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(EQUALS(svInt, 123), LESS_THAN_OR_EQUAL(svDouble, 200))"), null, null)); Review Comment: Let's change the expression to `svInt = 123 AND svDouble <= 200`. Users won't explicitly write query in this format -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org