Skip to content

Conversation

lowka
Copy link
Contributor

@lowka lowka commented Aug 28, 2025

Adds implementation of java.sql.ResultSet backed by ignite.sql.ResultSet.

https://issues.apache.org/jira/browse/IGNITE-26140


Thank you for submitting the pull request.

To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:

The Review Checklist

  • Formal criteria: TC status, codestyle, mandatory documentation. Also make sure to complete the following:
    - There is a single JIRA ticket related to the pull request.
    - The web-link to the pull request is attached to the JIRA ticket.
    - The JIRA ticket has the Patch Available state.
    - The description of the JIRA ticket explains WHAT was made, WHY and HOW.
    - The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • Design: new code conforms with the design principles of the components it is added to.
  • Patch quality: patch cannot be split into smaller pieces, its size must be reasonable.
  • Code quality: code is clean and readable, necessary developer documentation is added if needed.
  • Tests code quality: test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.

Notes

Copy link
Contributor

@korlov42 korlov42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the rate of comments in this PR, I request to split it on several parts up to 1k each in total (production + tests)

*/
public class JdbcResultSet implements ResultSet {
/** Decimal format to convert string to decimal. */
private static final ThreadLocal<DecimalFormat> decimalFormat = new ThreadLocal<>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this formatter? AFAIS, conversion from string to BD is as simple as new BigDecimal(s.trim())


private int fetchSize;

private SqlRow currentRow;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's mark as @Nullable

return false;
}
currentRow = rs.next();
currentPosition += 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: currentPosition++ seems more natural to me

@Override
public boolean wasNull() throws SQLException {
ensureNotClosed();
ensureHasCurrentRow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensureHasCurrentRow() doesn't feel correct in this context. Assume I've read the entire dataset, and now I would like to check if the last column of the last row was null. The last column access resulted in NULL (in fact this doesn't matter, let's just stick with particular value for simplicity), but this method will throw an exception. But if I requested the very first row but but didn't access any column, this method returns false.

I think, we either need to ensure column access, or just return current value of wasNull attribute with value false in case there has not been column access yet (personally, I prefer to stick with the latter for simplicity)


/** {@inheritDoc} */
@Override
public String getString(int colIdx) throws SQLException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's mark return type of all getters as @Nullable

@Override
public void close() throws SQLException {
closed = true;
rs.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's declared that method close throws java.sql.SQLException, but method close on org.apache.ignite.sql.ResultSet may throw any sort of Ignite-specific-and-not-only errors. We need to introduce exception conversion

} else if (value instanceof Instant) {
LocalDateTime localDateTime = instantWithLocalTimeZone((Instant) value);

initMetadata();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first, why do we need lazy initialization in case of simple wrappers like JdbcResultSetMetadata?

second, meta is used all temporal types but initialized only for value of class Instant. How is it supposed to work for LocalTime and LocalDateTime . We need to improve test coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants