tkalkirill commented on code in PR #5004:
URL: https://github.com/apache/calcite/pull/5004#discussion_r3414585488
##########
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:
Sorry for the delayed reply; I was away on a short vacation.
I tested the queries in the current implementation:
```
select * from person fetch next (? + abs(2)) rows only; --will **work**.
select * from person fetch next ? + abs(2) rows only; --will **fail** with a
parsing error.
--
select * from person fetch next (select 2) rows only; --will **fail** with a
parsing error.
select * from person fetch next (select ?) rows only; --will **fail** with a
parsing error.
select * from person fetch next (select max(id) from peson) rows only;
--will **fail** with a parsing error.
```
I tested queries containing `SELECT` subqueries in Postgres, and they all
executed successfully. In my current change, I proposed supporting only
arithmetic operations and scalar expressions—excluding subqueries, even scalar
ones.
I suggest adding support for them as a separate task later on, should the
need arise.
I am currently adding tests for the aforementioned queries.
@xiedeyantu @xuzifu666 What do you think?
--
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]