lowka commented on code in PR #3953:
URL: https://github.com/apache/ignite-3/pull/3953#discussion_r1650758305
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/api/ItSqlSynchronousApiTest.java:
##########
@@ -131,4 +139,99 @@ public void process(ResultSet<SqlRow> resultSet) {
resultSet.forEachRemaining(res::add);
}
}
+
+ @Test
+ public void testEarlyQueryTimeout() {
+ Statement stmt = igniteSql().statementBuilder()
+ .query("SELECT * FROM TABLE(SYSTEM_RANGE(1,
1000000000000000))")
+ .queryTimeout(1, TimeUnit.MILLISECONDS)
+ .build();
+
+ // Do not have enough time to do anything.
+ assertThrowsSqlException(Sql.EXECUTION_CANCELLED_ERR, "Query timeout",
() -> {
+ igniteSql().execute(null, stmt);
+ });
+ }
+
+ @Test
+ public void testQueryTimeout() {
+ Statement stmt = igniteSql().statementBuilder()
+ .query("SELECT * FROM TABLE(SYSTEM_RANGE(1,
1000000000000000))")
+ .queryTimeout(100, TimeUnit.MILLISECONDS)
+ .build();
+
+ ResultSet<SqlRow> rs;
+ while (true) {
+ try {
+ rs = igniteSql().execute(null, stmt);
+ break;
+ } catch (SqlException e) {
+ if (e.code() == Sql.PLANNING_TIMEOUT_ERR || e.code() ==
Sql.EXECUTION_CANCELLED_ERR) {
+ continue;
+ }
+ fail(e.getMessage());
+ }
+ }
+ ResultSet<SqlRow> resultSet = rs;
+ assertNotNull(resultSet);
+
+ // Read data until exception occurs.
+ assertThrowsSqlException(Sql.EXECUTION_CANCELLED_ERR, "Query timeout",
() -> {
+ while (resultSet.hasNext()) {
+ resultSet.next();
+ }
+ });
+ }
+
+ @Test
+ public void testQueryTimeoutIsPropagatedFromTheServer() throws Exception {
Review Comment:
IntelliJ's static analyser does not like that line of code either. It
expects an NPE here.
I guess it is time to fix it by adding some guard condition.
--
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]