Skip to content

Conversation

@vdonato
Copy link
Collaborator

@vdonato vdonato commented Mar 29, 2023

Note: This PR is targeting the vdonato/sql-connection branch for now so that the diff looks nicer.
We'll retarget it to feature/st.experimental_connection once the other branch is merged.

📚 Context

This PR adds an implementation of another first party connection class: the Snowpark connection.
This connection is a thin wrapper around the snowflake-snowpark-python library to make it play nicely
with the st.experimental_connection factory function. It also implements locking around operations with
the underlying library so that the app author doesn't have to think of thread safety.

Similarly to with our SQL connector, there's still a bit of work to do for this one:

  • Retries for the read_sql method still need to be implemented.
  • We need to add some unit tests for the class itself. This will be done in a later PR.

@vdonato vdonato force-pushed the vdonato/sql-connection branch from 98976a0 to 1cfede6 Compare March 29, 2023 00:13
@vdonato vdonato force-pushed the vdonato/snowpark-connection branch from 7098a36 to 04d5900 Compare March 29, 2023 00:14
@vdonato vdonato added the security-assessment-completed Security assessment has been completed for PR label Mar 29, 2023
@vdonato vdonato force-pushed the vdonato/snowpark-connection branch from 04d5900 to 74a63af Compare March 29, 2023 00:38
@vdonato vdonato requested review from kmcgrady and mayagbarnes March 29, 2023 00:38
Comment on lines -6 to -7
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of the changes that aren't adding typechecking to the py_snowflake below were done by the autoformatter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll probably also make a second PR to make these changes straight to develop to shrink the diff for the feature branch tomorrow

@vdonato vdonato force-pushed the vdonato/snowpark-connection branch from 74a63af to 09f1a4a Compare March 29, 2023 00:51
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Just a few small potential improvements

Copy link
Collaborator

Choose a reason for hiding this comment

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

kwargs seems to be unused at the moment. I assume it should be used to overwrite the conn_params, or?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we could be more explicit with the config options here? E.g.:

def connect(self, account: Optional[str], user: Optional[str], ..., **kwargs) + a good docstring explaining the options.

It is probably enough to only cover the most common options, and leave the rest to kwargs. By not doing this, we might require the user to figure out the config options on their own by finding them in the underlying library. Which is a bit contrary to the promise of simplifying connections. Of course, just putting info about the config options into our documentation could also be an option.

Having this somehow more explicit could also be very useful for autogenerating the connection wizard later.

Linking @sfc-gh-jcarroll here since this is also bridging a bit into product.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree covering the common options is a good idea. Not necessarily a ship blocker but definitely something to do before GA and it'll be nicer if it's done now.

Similar to the practice I described here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack -- I have a separate ticket filed to figure out how to merge what's found in files / secrets / kwargs to the object passed to connection params, so I'll address this as part of that work item

@vdonato vdonato force-pushed the vdonato/sql-connection branch from 1cfede6 to 6245642 Compare March 29, 2023 21:58
@vdonato vdonato force-pushed the vdonato/snowpark-connection branch 4 times, most recently from 7123ade to da334f6 Compare March 31, 2023 00:04
Base automatically changed from vdonato/sql-connection to feature/st.experimental_connection March 31, 2023 00:16
@vdonato vdonato force-pushed the feature/st.experimental_connection branch from 3e1b2a4 to fa6351b Compare March 31, 2023 00:18
@vdonato vdonato force-pushed the vdonato/snowpark-connection branch from da334f6 to 9ac5276 Compare March 31, 2023 00:20
@vdonato vdonato merged this pull request into feature/st.experimental_connection Mar 31, 2023
@vdonato vdonato deleted the vdonato/snowpark-connection branch March 31, 2023 00:50
vdonato added a commit that referenced this pull request Mar 31, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 4, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 6, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 6, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 10, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 11, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 15, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 17, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 19, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 20, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
vdonato added a commit that referenced this pull request Apr 21, 2023
* Add a first party Snowpark connection

* Use the new AttrDict.to_dict() method

* Add a unit test for Snowpark.read_sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants