-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85cb3c7
commit 625519f
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from snowflake.snowpark import Session | ||
|
||
connection_parameters: dict[str, int | str] = { | ||
"user": "<user_name>", | ||
"password": "<password>", | ||
"account": "<account_name>", | ||
"role": "<role_name>", | ||
"warehouse": "<warehouse_name>", | ||
"database": "<database_name>", | ||
"schema": "<schema_name>", | ||
} | ||
|
||
session = Session.builder.configs(connection_parameters).create() | ||
|
||
df = session.create_dataframe( | ||
[["John", "Berry"], ["Rick", "Berry"], ["Anthony", "Davis"]], | ||
schema=["FIRST_NAME", "LAST_NAME"], | ||
) | ||
|
||
remote_file_path = f"{session.get_session_stage()}/names.parquet" | ||
|
||
copy_result = df.write.copy_into_location( | ||
remote_file_path, | ||
file_format_type="parquet", | ||
header=True, | ||
overwrite=True, | ||
single='hoge', | ||
) | ||
|
||
|
||
|
||
from typing import Optional, TypedDict, Literal, overload, Unpack, Union | ||
|
||
class Hoge(TypedDict, total=False): | ||
fuga: Literal['hoge', 'fuga'] | ||
hogehoge: bool | ||
|
||
|
||
@overload | ||
def get_hoge(fuga: Literal[True], *, hoge: Optional[str] = '', **kwargs: str) -> None: | ||
... | ||
@overload | ||
def get_hoge(fuga: Literal[False], *, hoge: Optional[str] = None, **kwargs: str) -> bool: | ||
... | ||
|
||
def get_hoge(fuga: bool, *, hoge: Optional[str] = '', **kwargs: str) -> Union[None, bool]: | ||
if fuga: | ||
return None | ||
return False | ||
|
||
def get_fuga(fuga: bool, *, hogehoge: bool = False, fugafuga: bool = True): | ||
get_hoge(fuga) | ||
|
||
get_fuga(fuga=True, fugafuga=False) | ||
|