-
Notifications
You must be signed in to change notification settings - Fork 110
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-896744: Allow creating dataframes using tuples as schema #1025
SNOW-896744: Allow creating dataframes using tuples as schema #1025
Conversation
src/snowflake/snowpark/session.py
Outdated
@@ -1865,7 +1865,7 @@ def write_pandas( | |||
def create_dataframe( | |||
self, | |||
data: Union[List, Tuple, "pandas.DataFrame"], | |||
schema: Optional[Union[StructType, List[str]]] = None, | |||
schema: Optional[Union[StructType, List[str], Tuple[str]]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make sure we use schema
as an iterable when it is not StructType
, and then support Iterable[str]
?
@@ -325,7 +325,7 @@ def infer_type(obj: Any) -> DataType: | |||
|
|||
|
|||
def infer_schema( | |||
row: Union[Dict, List, Tuple], names: Optional[List] = None | |||
row: Union[Dict, List, Tuple], names: Optional[Union[List, Tuple]] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we could do names.extend
when names
is a tuple? How about we explicitly copy names
into a list first? This way we could support Iterable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I can convert iterable into a list and then assume list datatype from thereon...
Did not mean to "requested changes". The change looks good overall but wonder if we could extend to |
Please answer these questions before submitting your pull requests. Thanks!
What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-896744: creating a DataFrame with a tuple of names will be ignored an generic names will be used #1009
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.