Druid Avatica JDBC driver does not honor `Statement.setMaxRows()`
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
# Druid Avatica JDBC driver does not honor `Statement.setMaxRows()`
## Description
The Druid JDBC driver does not appear to honor the JDBC `Statement.setMaxRows(int)` setting.
According to the JDBC API, `setMaxRows()` specifies the maximum number of rows that a `Statement` should return. However, when using the Druid Avatica JDBC driver, setting `maxRows` does not limit the number of rows returned in the `ResultSet`.
## Steps to reproduce
1. Connect to Druid using the Avatica JDBC driver.
2. Create a `PreparedStatement`.
3. Set `setMaxRows(5)`.
4. Execute a query that returns more than 5 rows.
5. Iterate over the `ResultSet`.
Sample Code Snippet
```java
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(sqlQuery)) {
preparedStatement.setMaxRows(maxRecordsToReturn);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
//......
}
}
```
Version Used
```xml
org.apache.calcite.avatica
avatica-core
1.28.0
```
Contributor guide
Research direction
Start by reproducing the issue with the provided PreparedStatement example against Druid using Avatica JDBC driver version 1.28.0, setting maxRows to 5 and executing a query returning more than 5 rows. Trace the driver’s setMaxRows and executeQuery handling, then verify that iterating the ResultSet never returns more than the configured maximum.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100