asolimando commented on code in PR #3858:
URL: https://github.com/apache/calcite/pull/3858#discussion_r1681688817
##########
arrow/src/main/java/org/apache/calcite/adapter/arrow/ArrowTranslator.java:
##########
@@ -185,6 +187,34 @@ private String translateOp2(String op, String name,
RexLiteral right) {
return name + " " + op + " " + valueString + " " + valueType;
}
+ /** Translates a call to a unary operator. */
+ private String translateUnary(String op, RexCall call) {
+ final RexNode opNode = call.operands.get(0);
+ @Nullable String expression = translateUnary2(op, opNode);
+
+ if (expression != null) {
+ return expression;
+ }
+
+ throw new UnsupportedOperationException("Unsupported unary operator " +
call);
+ }
+
+ /** Translates a call to a unary operator. Returns null on failure. */
+ private @Nullable String translateUnary2(String op, RexNode opNode) {
+ if (opNode.getKind() == SqlKind.INPUT_REF) {
+ final RexInputRef inputRef = (RexInputRef) opNode;
Review Comment:
I don't think it's necessary, as you have noticed it's a common pattern to
rely on `SqlKind` to infer the dynamic type of a `RexNode` object instead of
`instanceof`, for me it's good as-is
--
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]