walterddr commented on code in PR #9374:
URL: https://github.com/apache/pinot/pull/9374#discussion_r971147230
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/RexExpression.java:
##########
@@ -52,30 +51,32 @@ static RexExpression toRexExpression(RexNode rexNode) {
} else if (rexNode instanceof RexLiteral) {
RexLiteral rexLiteral = ((RexLiteral) rexNode);
FieldSpec.DataType dataType = toDataType(rexLiteral.getType());
- return new RexExpression.Literal(dataType, rexLiteral.getTypeName(),
- toRexValue(dataType, rexLiteral.getValue()));
+ return new RexExpression.Literal(dataType, toRexValue(dataType,
rexLiteral.getValue()));
} else if (rexNode instanceof RexCall) {
RexCall rexCall = (RexCall) rexNode;
- List<RexExpression> operands =
rexCall.getOperands().stream().map(RexExpression::toRexExpression)
- .collect(Collectors.toList());
- return toRexExpression(rexCall, operands);
+ return toRexExpression(rexCall);
} else {
throw new IllegalArgumentException("Unsupported RexNode type with
SqlKind: " + rexNode.getKind());
}
}
- static RexExpression toRexExpression(RexCall rexCall, List<RexExpression>
operands) {
+ static RexExpression toRexExpression(RexCall rexCall) {
+ List<RexExpression> operands;
switch (rexCall.getKind()) {
case CAST:
// CAST is being rewritten into "rexCall.CAST<targetType>(inputValue)",
// - e.g. result type has already been converted into the CAST
RexCall, so we assert single operand.
+ operands =
rexCall.getOperands().stream().map(RexExpression::toRexExpression).collect(Collectors.toList());
Preconditions.checkState(operands.size() == 1, "CAST takes exactly 2
arguments");
RelDataType castType = rexCall.getType();
// add the 2nd argument as the source type info.
- operands.add(new Literal(FieldSpec.DataType.STRING,
rexCall.getOperands().get(0).getType().getSqlTypeName(),
+ operands.add(new Literal(FieldSpec.DataType.STRING,
toPinotDataType(rexCall.getOperands().get(0).getType()).name()));
return new RexExpression.FunctionCall(rexCall.getKind(),
toDataType(rexCall.getType()), "CAST", operands);
Review Comment:
can you also refactor this into `RexExpressionUtils.handleCast` ?
--
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]