siddharthteotia commented on code in PR #9909:
URL: https://github.com/apache/pinot/pull/9909#discussion_r1044782213
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/TransformOperand.java:
##########
@@ -18,26 +18,120 @@
*/
package org.apache.pinot.query.runtime.operator.operands;
+import com.clearspring.analytics.util.Preconditions;
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) {
+ int operandSize = functionCall.getFunctionOperands().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(functionCall.getFunctionOperands(),
inputDataSchema);
+ case "OR":
+ Preconditions.checkState(operandSize >= 2, "OR takes >=2 argument,
passed in argument size:" + operandSize);
+ return new FilterOperand.Or(functionCall.getFunctionOperands(),
inputDataSchema);
+ case "NOT":
+ Preconditions.checkState(operandSize == 1, "NOT takes one argument,
passed in argument size:" + operandSize);
+ return new
FilterOperand.Not(toTransformOperand(functionCall.getFunctionOperands().get(0),
inputDataSchema));
+ case "equals":
+ return new FilterOperand.Predicate(functionCall.getFunctionOperands(),
inputDataSchema) {
+ @Override
+ public Boolean apply(Object[] row) {
+ if (_requireCasting) {
+ return ((Comparable)
FunctionInvokeUtils.convert(_lhs.apply(row), _commonCastType)).compareTo(
+ FunctionInvokeUtils.convert(_rhs.apply(row),
_commonCastType)) == 0;
+ } else {
+ return ((Comparable) _lhs.apply(row)).compareTo(_rhs.apply(row))
== 0;
+ }
+ }
+ };
+ case "notEquals":
Review Comment:
This is all case-insensitive right ?
--
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]