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

Array binding support for filtering parameter #1002

Closed
nearsyh opened this issue Dec 13, 2023 · 3 comments
Closed

Array binding support for filtering parameter #1002

nearsyh opened this issue Dec 13, 2023 · 3 comments
Assignees
Labels
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 wontfix

Comments

@nearsyh
Copy link

nearsyh commented Dec 13, 2023

My code

row, err = db.QueryRow("SELECT ARRAY_CONTAINS('a'::variant, ?)", gosnowflake.Array([]string{"a", "b"}))

What is the current behavior?

We have a non-nil err. Error message is

Fail to get the query result: 002049 (42601): SQL compilation error: error line 1 at position 36
    Bind variable ? not set.

What is the desired behavior?

This query would complete successfully.

How would this improve gosnowflake?

It would make the SQL simpler. Currently, we need to change the code like below:

row, err = db.QueryRow("SELECT ARRAY_CONTAINS('a'::variant, SPLIT(?, ','))", strings.Join(arr, ","))
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Dec 13, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Dec 13, 2023
@sfc-gh-dszmolka
Copy link
Contributor

hi and thank you for submitting this enhancement request, also a possible workaround ! we'll take a look and see how it can be prioritized - it might take a while, so thank you in advance for bearing with us !

in the meantime, additional workaround if it makes sense for your environment, using ARRAY_CONSTRUCT to build the array, which can then conveniently take bind variables:

        selectQuery := "SELECT ARRAY_CONTAINS('a'::VARIANT, ARRAY_CONSTRUCT(?, ?));"
        rows, err := conn.QueryContext(ctx, selectQuery, "a", "b")

@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature and removed status-triage Issue is under initial triage labels Dec 13, 2023
@sfc-gh-dszmolka
Copy link
Contributor

as an initial estimation per current situation, feature can be expected earliest H2 2025 or later (for the Go driver). thank you everyone for bearing with us !

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label Mar 12, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hey folks - team just got to this issue. Upon reviewing it, it turns out it is a limitation on the backend. INSERT is the only one statement supported natively for array binding (on the backend) . The driver prepares the statement the exactly same way for all the other types of queries. For SELECT, UPDATE, etc. first of all, the backend (==Snowflake itself) needs to support this functionality, and this is driver-independent.

As a workaround, the already mentioned ways can be used.

To move forward with this issue, please reach out to your Snowflake account team and let them know how important it is for you to have Snowflake backend support array binding for non-INSERT statements. They can work with the relevant teams responsible for the Snowflake engine and implement this functionality to be available for all drivers (besides gosnowflake)

@sfc-gh-dszmolka sfc-gh-dszmolka closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 wontfix
Projects
None yet
Development

No branches or pull requests

3 participants