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

Open
nearsyh opened this issue Dec 13, 2023 · 2 comments
Open

Array binding support for filtering parameter #1002

nearsyh opened this issue Dec 13, 2023 · 2 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

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
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
Projects
None yet
Development

No branches or pull requests

3 participants