Skip to content

SNOW-2013774 support server side semi structured types bindings #2269

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 4 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-mkubik
Copy link
Contributor

@sfc-gh-mkubik sfc-gh-mkubik commented Apr 14, 2025

Changes:

  • add snowflake_type parameter to cursor.execute that indicates what is the desired snowflake type. If it's one of the semi-structured types, there's a special handling that includes serialising the object to JSON string that gets passed to the backend with appropriate type.
  • integ tests

No snowflake_type provided or snowflake_type other than ARRAY, OBJECT or VARIANT doesn't change the processing flow. If user provides the primitive type e.g. BOOLEAN but the binding logic interprets it differently it results in a warning.

@sfc-gh-mkubik sfc-gh-mkubik added the DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector label Apr 14, 2025
@sfc-gh-mkubik sfc-gh-mkubik marked this pull request as ready for review April 14, 2025 15:23
@sfc-gh-mkubik sfc-gh-mkubik force-pushed the SNOW-2013774-support-server-side-semi-structured-types-bindings branch from 40b2c0d to 930573f Compare April 15, 2025 06:08
cursor.execute(
bind_query, params=(["a", "b", "c"],), snowflake_type=snowflake_type
)
cursor.execute(bind_query, params=([1, "2", 3],), snowflake_type=snowflake_type)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was also an option to introduce a wrapper types or functions to point that a semi-structured binding should be used? I.e. in that case this line would look like:
cursor.execute(bind_query, params=(snow_array([1, "2", 3]),))
Or snow_object in the test below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't think of it but that's a pretty elegant idea, let me adjust the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants