xiedeyantu commented on code in PR #5004:
URL: https://github.com/apache/calcite/pull/5004#discussion_r3384863786
##########
core/src/main/java/org/apache/calcite/rex/RexUtil.java:
##########
@@ -840,6 +840,25 @@ public static boolean isDeterministic(RexNode e) {
}
}
+ /** Returns whether an expression contains a dynamic function. */
+ public static boolean containsDynamicFunction(RexNode e) {
+ try {
+ e.accept(
+ new RexVisitorImpl<Void>(true) {
+ @Override public Void visitCall(RexCall call) {
+ if (call.getOperator().isDynamicFunction()) {
+ throw Util.FoundOne.NULL;
Review Comment:
I see many checks for whether parameters are dynamic. Is it possible to
converge to a single utility method?
##########
core/src/test/java/org/apache/calcite/test/JdbcTest.java:
##########
@@ -5977,6 +6038,106 @@ private CalciteAssert.AssertQuery withEmpDept(String
sql) {
Matchers.returnsUnordered("name=Eric"));
}
+ /** Tests dynamic parameters in parenthesized FETCH expressions. */
+ @Test void testPreparedFetchExpression() throws Exception {
+ CalciteAssert.that()
+ .doWithConnection(connection -> {
+ final String values =
+ "select * from (values (1), (2), (3), (4)) as t(x)\n";
+ checkPreparedFetch(connection, values + "fetch next (?) rows only",
+ 2, "X=1\nX=2\n");
+ checkPreparedFetch(connection, values + "fetch next (? + 1) rows
only",
Review Comment:
Will it support `? + abs(2)` and `fetch next (select 2)` or `fetch next
(select max(col)) from t)`?
--
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]