walterddr commented on code in PR #9909:
URL: https://github.com/apache/pinot/pull/9909#discussion_r1044885616
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/TransformOperand.java:
##########
@@ -18,26 +18,123 @@
*/
package org.apache.pinot.query.runtime.operator.operands;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
import org.apache.pinot.common.utils.DataSchema;
import org.apache.pinot.query.planner.logical.RexExpression;
+import org.apache.pinot.query.runtime.operator.utils.FunctionInvokeUtils;
+import org.apache.pinot.query.runtime.operator.utils.OperatorUtils;
public abstract class TransformOperand {
protected String _resultName;
protected DataSchema.ColumnDataType _resultType;
- public static TransformOperand toTransformOperand(RexExpression
rexExpression, DataSchema dataSchema) {
+ public static TransformOperand toTransformOperand(RexExpression
rexExpression, DataSchema inputDataSchema) {
if (rexExpression instanceof RexExpression.InputRef) {
- return new ReferenceOperand((RexExpression.InputRef) rexExpression,
dataSchema);
+ return new ReferenceOperand((RexExpression.InputRef) rexExpression,
inputDataSchema);
} else if (rexExpression instanceof RexExpression.FunctionCall) {
- return new FunctionOperand((RexExpression.FunctionCall) rexExpression,
dataSchema);
+ return toTransformOperand((RexExpression.FunctionCall) rexExpression,
inputDataSchema);
} else if (rexExpression instanceof RexExpression.Literal) {
return new LiteralOperand((RexExpression.Literal) rexExpression);
} else {
throw new UnsupportedOperationException("Unsupported RexExpression: " +
rexExpression);
}
}
+ @SuppressWarnings({"ConstantConditions", "rawtypes", "unchecked"})
+ private static TransformOperand
toTransformOperand(RexExpression.FunctionCall functionCall,
+ DataSchema inputDataSchema) {
+ final List<RexExpression> functionOperands =
functionCall.getFunctionOperands();
+ int operandSize = functionOperands.size();
+ switch
(OperatorUtils.canonicalizeFunctionName(functionCall.getFunctionName())) {
+ case "AND":
+ Preconditions.checkState(operandSize >= 2, "AND takes >=2 argument,
passed in argument size:" + operandSize);
+ return new FilterOperand.And(functionOperands, inputDataSchema);
+ case "OR":
+ Preconditions.checkState(operandSize >= 2, "OR takes >=2 argument,
passed in argument size:" + operandSize);
+ return new FilterOperand.Or(functionOperands, inputDataSchema);
+ case "NOT":
+ Preconditions.checkState(operandSize == 1, "NOT takes one argument,
passed in argument size:" + operandSize);
+ return new FilterOperand.Not(functionOperands.get(0), inputDataSchema);
+ case "equals":
+ return new FilterOperand.Predicate(functionOperands, inputDataSchema) {
+ @Override
+ public Boolean apply(Object[] row) {
Review Comment:
yes. we are considering this but will probably not get to it until next year
:-/
--
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]