Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flight JDBC Driver not setting parameter correctly when parameter type is DATE<MILLISECOND> #477

Open
jeremy-drmio opened this issue Jan 3, 2025 · 0 comments
Labels
Type: bug Something isn't working

Comments

@jeremy-drmio
Copy link

Describe the bug, including details regarding any error messages, version, and platform.

Arrow Version 17.0.0

When executing a prepared statement using the Arrow Flight JDBC driver, the driver sets the value for date parameters as DAYS since unix epoch, even when the parameter type returned by the server is DATE(MILLISECONDS).

https://github.com/apache/calcite-avatica/blob/2baa36e493cd90b89a6dec5cb04db0eefe6aef93/core/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java#L1344-L1361

The parameter converter below sets the same value regardless of the type. This results in the server receiving an unexpected parameter value.

https://github.com/apache/arrow/blob/6a2e19a852b367c72d7b12da4d104456491ed8b7/java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/DateAvaticaParameterConverter.java#L33-L43

    Properties props = new Properties();
    String connection = "jdbc:arrow-flight-sql://xx:xx/?useEncryption=false";
    String query = "select date from T where date = ?";

    try (Connection con = DriverManager.getConnection(connection, props);
         PreparedStatement ps = con.prepareStatement(query)) {

      ps.setDate(1, Date.valueOf(LocalDate.of(2000, 1, 1)), null);

      try (ResultSet rs = ps.executeQuery()) {
        rs.next();
      }
    }

Component(s)

Java

@jeremy-drmio jeremy-drmio added the Type: bug Something isn't working label Jan 3, 2025
@kou kou transferred this issue from apache/arrow Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant