Skip to content

Snow-1936378 add support for vector type for loader #2161

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

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-ext-simba-jf
Copy link
Collaborator

Overview

SNOW-XXXXX

Pre-review self checklist

  • PR branch is updated with all the changes from master branch
  • The code is correctly formatted (run mvn -P check-style validate)
  • New public API is not unnecessary exposed (run mvn verify and inspect target/japicmp/japicmp.html)
  • The pull request name is prefixed with SNOW-XXXX:
  • Code is in compliance with internal logging requirements

External contributors - please answer these questions before submitting a pull request. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Issue: #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency or upgrading an existing one
    • I am adding new public/protected component not marked with @SnowflakeJdbcInternalApi (note that public/protected methods/fields in classes marked with this annotation are already internal)
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

@sfc-gh-snowflakedb-snyk-sa
Copy link
Contributor

sfc-gh-snowflakedb-snyk-sa commented Apr 21, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@sfc-gh-ext-simba-jf sfc-gh-ext-simba-jf marked this pull request as ready for review April 28, 2025 05:38
@sfc-gh-ext-simba-jf sfc-gh-ext-simba-jf requested a review from a team as a code owner April 28, 2025 05:38
for (String col : _columns) {
try (ResultSet rs = metadata.getColumns(_database, _schema, _table, col)) {
// Check if column type is VECTOR, if true, add column name and size to vector column map.
if (rs.getString(6).equalsIgnoreCase("vector")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we extract the logic of this condition and name this check instead of a comment?

@@ -83,6 +85,8 @@ public class StreamLoader implements Loader, Runnable {

private List<String> _columns;

private Map<String, Integer> _vectorColumns = new HashMap<String, Integer>();
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to update the name of this map to better communicate its function: keep column size.

for (int i = 0; i < _columns.size(); i++) {
String colName = _columns.get(i);
if (_vectorColumns.containsKey(colName)) {
sb.append(colName + "::VECTOR(FLOAT, " + _vectorColumns.get(colName) + ")");
Copy link
Contributor

Choose a reason for hiding this comment

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

What about INT types in a vector?


@Test
@DontRunOnGithubActions
private void testMultipleVectorColumnsInTable() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also test the table with mixed types (the best with all types).

for (String col : _columns) {
try (ResultSet rs = metadata.getColumns(_database, _schema, _table, col)) {
// Check if column type is VECTOR, if true, add column name and size to vector column map.
if (rs.getString(6).equalsIgnoreCase("vector")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to store metadata for all columns, not only for the vector, in my opinion.

@sfc-gh-ext-simba-hx sfc-gh-ext-simba-hx requested review from sfc-gh-pbulawa and sfc-gh-dheyman and removed request for sfc-gh-pmotacki June 30, 2025 15:57
Copy link
Collaborator

@sfc-gh-pbulawa sfc-gh-pbulawa left a comment

Choose a reason for hiding this comment

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

Can we have a test that checks the INT Vector?

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.

4 participants