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

Using PreparedStatement with Vectors (SNOW-1260139) #2037

Open
mhryb opened this issue Jan 17, 2025 · 1 comment
Open

Using PreparedStatement with Vectors (SNOW-1260139) #2037

mhryb opened this issue Jan 17, 2025 · 1 comment
Assignees
Labels
backend changes needed Change must be implemented on the Snowflake service, and not in the client driver. enhancement The issue is a request for improvement or a new feature status-blocked Progress cannot be made to this issue due to an outside blocking factor. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@mhryb
Copy link

mhryb commented Jan 17, 2025

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of JDBC driver are you using?
    3.21.0

  2. What operating system and processor architecture are you using?
    Windows 10

  3. What version of Java are you using?
    17

  4. What did you do?

I try to use PreparedStatement with different approaches:

String insertSQL = "INSERT INTO test_vectors SELECT ?::VECTOR(FLOAT,3), ?::VECTOR(FLOAT,3)";
        try {
            Connection connection = DriverManager.getConnection(connectionUrl);
            PreparedStatement stmt = connection.prepareStatement(insertSQL);
            stmt.setArray(1, connection.createArrayOf("NUMBER", List.of(1,2,3).toArray()));
            stmt.setArray(2, connection.createArrayOf("NUMBER", List.of(1,2,3).toArray()));
            int rowsInserted = stmt.executeUpdate();
            if (rowsInserted > 0) {
                System.out.println("A new record was inserted successfully.");
            }
            stmt.close();
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

But I got an error: net.snowflake.client.jdbc.SnowflakeLoggedFeatureNotSupportedException

String insertSQL = "INSERT INTO test_vectors SELECT strtok_to_array(?, ',')::VECTOR(FLOAT,3), strtok_to_array(?, ',')::VECTOR(FLOAT,3)";
        try {
            Connection connection = DriverManager.getConnection(connectionUrl);
            PreparedStatement stmt = connection.prepareStatement(insertSQL);
            stmt.setString(1, "1,2,3");    
            stmt.setString(2, "1,2,3");  
            int rowsInserted = stmt.executeUpdate();
            if (rowsInserted > 0) {
                System.out.println("A new record was inserted successfully.");
            }
            stmt.close();
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        }

With this example I got error: net.snowflake.client.jdbc.SnowflakeSQLException: Array-like value being cast to a float vector has elements that are not real numbers

Also I tried to use stmt.setString(), stmt.setObject(). I changed the sql query:
"INSERT INTO test_vectors SELECT ?::VECTOR(FLOAT,3), ?::VECTOR(FLOAT,3)" but nothing helped.

Is there a way to use vectors with PreparedStatement?

  1. What did you expect to see?

    I expect that I can use vectors with PreparedStatement.

@mhryb mhryb added the bug label Jan 17, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team backend changes needed Change must be implemented on the Snowflake service, and not in the client driver. status-blocked Progress cannot be made to this issue due to an outside blocking factor. and removed bug labels Jan 20, 2025
@sfc-gh-dszmolka
Copy link
Contributor

hi - thank you for your interest in this feature (using VECTOR datatype with variable binding in JDBC driver).
Currently, this use-case is unfortunately not supported.

It is indeed on the team's plans, without any committed timeline. I'll keep this thread posted if there's any new information on this topic. In the meantime, if you're already a Snowflake customer, please reach out to your Account Team and let them know how much you would need this capability.

@sfc-gh-dszmolka sfc-gh-dszmolka changed the title Using PreparedStatement with Vectors Using PreparedStatement with Vectors (SNOW-1260139) Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend changes needed Change must be implemented on the Snowflake service, and not in the client driver. enhancement The issue is a request for improvement or a new feature status-blocked Progress cannot be made to this issue due to an outside blocking factor. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants