Skip to content

Commit

Permalink
fix: Fixed bug in passing config file params to snowflake python conn…
Browse files Browse the repository at this point in the history
…ector (#2503)

* fixed bug in passing config file params to snowflake python connector

Signed-off-by: Miles Adkins <[email protected]>

* removed .keys() bug

Signed-off-by: Miles Adkins <[email protected]>

* fixed schema assignment error

Signed-off-by: Miles Adkins <[email protected]>
  • Loading branch information
sfc-gh-madkins authored Apr 7, 2022
1 parent 1279612 commit 34f2b59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/offline_stores/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SnowflakeOfflineStoreConfig(FeastConfigBaseModel):
database: Optional[str] = None
""" Snowflake database name """

schema_: Optional[str] = Field("PUBLIC", alias="schema")
schema_: Optional[str] = Field(None, alias="schema")
""" Snowflake schema name """

class Config:
Expand Down
18 changes: 12 additions & 6 deletions sdk/python/feast/infra/utils/snowflake_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ def get_snowflake_conn(config, autocommit=True) -> SnowflakeConnection:
else:
kwargs = {}

if "schema" in kwargs:
kwargs["schema_"] = kwargs.pop("schema")

kwargs.update((k, v) for k, v in config_dict.items() if v is not None)
[
kwargs.update({k: '"' + v + '"'})
for k, v in kwargs.items()
if k in ["role", "warehouse", "database", "schema_"]
]
kwargs["schema"] = kwargs.pop("schema_")

for k, v in kwargs.items():
if k in ["role", "warehouse", "database", "schema_"]:
kwargs[k] = f'"{v}"'

if "schema_" in kwargs:
kwargs["schema"] = kwargs.pop("schema_")
else:
kwargs["schema"] = '"PUBLIC"'

try:
conn = snowflake.connector.connect(
Expand Down

0 comments on commit 34f2b59

Please sign in to comment.