Jackie-Jiang commented on code in PR #19768:
URL: https://github.com/apache/pinot/pull/19768#discussion_r4201429114
##########
pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/RexExpressionUtilsTest.java:
##########
@@ -71,6 +72,36 @@ public void testUuidLiteralRoundTrip() {
Assert.assertEquals(roundTrip.getValue(), uuid);
}
+ @Test
+ public void testSqlKindFunctionNames() {
+ // Plan nodes name most standard operators by SqlKind, e.g. DIVIDE for "/"
and SUM0 for "$SUM0"
+ RelBuilder relBuilder =
RelBuilder.create(Frameworks.newConfigBuilder().build()).values(new
String[]{"a"}, 1.0);
+ RexExpression input = new RexExpression.InputRef(0);
+ List<RexExpression> inOperands = List.of(input, new
RexExpression.Literal(ColumnDataType.DOUBLE, 1.0),
+ new RexExpression.Literal(ColumnDataType.DOUBLE, 2.0));
+ for (RexExpression call : List.of(
+ new RexExpression.FunctionCall(ColumnDataType.DOUBLE,
SqlKind.DIVIDE.name(), List.of(input, input)),
+ new RexExpression.FunctionCall(ColumnDataType.BOOLEAN,
SqlKind.IN.name(), inOperands),
+ new RexExpression.FunctionCall(ColumnDataType.BOOLEAN,
SqlKind.NOT_IN.name(), inOperands))) {
+
Assert.assertEquals(RexExpressionUtils.fromRexNode(RexExpressionUtils.toRexNode(relBuilder,
call)), call);
+ }
+ RexExpression.FunctionCall sum0 =
+ new RexExpression.FunctionCall(ColumnDataType.DOUBLE,
SqlKind.SUM0.name(), List.of(input));
+ Assert.assertSame(RexExpressionUtils.getAggFunction(sum0),
SqlStdOperatorTable.SUM0);
+ }
+
+ @Test
+ public void testCastRoundTrip() {
+ // Plan nodes hold the target type of CAST as a STRING literal operand.
Field "a" is a nullable INTEGER.
+ RelBuilder relBuilder =
+ RelBuilder.create(Frameworks.newConfigBuilder().build()).values(new
String[]{"a"}, 1, null);
+ RexExpression castCall = new
RexExpression.FunctionCall(ColumnDataType.DOUBLE, SqlKind.CAST.name(),
+ List.of(new RexExpression.InputRef(0), new
RexExpression.Literal(ColumnDataType.STRING, "DOUBLE")));
+ RexNode rexNode = RexExpressionUtils.toRexNode(relBuilder, castCall);
+ Assert.assertTrue(rexNode.getType().isNullable());
+ Assert.assertEquals(RexExpressionUtils.fromRexNode(rexNode), castCall);
Review Comment:
Nit: Please use static imports for `assertTrue` and `assertEquals` in the
new test, following the test assertion convention.
--
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]