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

SNOW-892284: Fix boolean parameter parsing from URL query #439

Closed
wants to merge 0 commits into from

Conversation

saulbein
Copy link
Contributor

@saulbein saulbein commented Aug 14, 2023

Please answer these questions before submitting your pull requests. Thanks!

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

    Fixes SNOW-892284: Boolean URL connection parameters are passed down to the driver as strings #438

  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 adding new credentials
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Re-parses the booleans that become stringified by SQLAlchemy using the DEFAULT_PARAMETERS map from the connector that lists which parameters are boolean-typed. Not sure what to do with other types, such as integers, dicts or callables - I'm also not sure those work right now either way.

@saulbein
Copy link
Contributor Author

@sfc-gh-stan have you had a chance to look at the PR already?

Copy link
Collaborator

@sfc-gh-stan sfc-gh-stan left a comment

Choose a reason for hiding this comment

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

Hi @saulbein , so sorry for the delay. Your changes LGTM. I opened #446 to kick off the merge gates. Please add an entry in our changelog (DESCRIPTION.md) about this fix to pass Changelog Check.

@saulbein
Copy link
Contributor Author

@sfc-gh-stan The CI run found a small bug, fixed it now and added a note to the changelog.

@saulbein
Copy link
Contributor Author

@sfc-gh-stan Another fix, messed up the default case

@@ -226,10 +226,27 @@ def create_connect_args(self, url):
opts["host"] = opts["host"] + ".snowflakecomputing.com"
opts["port"] = "443"
opts["autocommit"] = False # autocommit is disabled by default
opts.update(url.query)

cache_column_metadata = opts.pop("cache_column_metadata", None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about setting using "False" as the default value and set self._cache_column_metadata = parse_url_boolean(opts.pop("cache_column_metadata", "False"))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a minor difference, I just prefer the code to not do parsing on constants if possible.

@saulbein
Copy link
Contributor Author

@sfc-gh-stan Another fix - the cache_column_metadata param was coming from the query part of the URL and I missed that the original code combined everything first. Unfortunately connection parameter tests are the hardest ones to run for me locally.

@saulbein
Copy link
Contributor Author

saulbein commented Oct 3, 2023

@sfc-gh-stan hey, could we get this through? I feel like this should be / is very close to working.

@saulbein
Copy link
Contributor Author

saulbein commented Oct 9, 2023

These lines is now whats causing issues (as they are unknown parameters). I guess passing arbitrary arguments is not prohibited, I think raising a warning makes the most sense it that case.

@saulbein
Copy link
Contributor Author

saulbein commented Oct 9, 2023

Adding warnings fails the SQLAlchemy test suite (it's set to error out on warnings) so for now I added a fallthrough without warnings. That can be a subject of a different PR as more investigation on how to set that up is needed.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2023
@sfc-gh-stan
Copy link
Collaborator

Hi @saulbein, I resolved a rebase conflict and fixed some linting to kick off the merge gates in #446. The merge gates passed. I tried pushing the changes to saulbein:main but that seemed to have closed this PR. Sorry for the inconveniences. Would you mind merging the changes from #446 instead or creating a new PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SNOW-892284: Boolean URL connection parameters are passed down to the driver as strings
2 participants