Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
share snowflake cursor and stage name
Signed-off-by: pyalex <moskalenko.alexey@gmail.com>
  • Loading branch information
pyalex committed Apr 29, 2022
commit b5ca9ac4615794d5b0f7f70a27a8d1a3340823f1
12 changes: 6 additions & 6 deletions sdk/python/feast/infra/utils/snowflake_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def write_pandas(

upload_df(df, cursor, stage_name, chunk_size, parallel, compression)
copy_uploaded_data_to_table(
conn,
cursor,
stage_name,
list(df.columns),
table_name,
database,
Expand Down Expand Up @@ -179,7 +180,8 @@ def write_parquet(
columns = [field.name for field in dataset_schema]
upload_local_pq(path, cursor, stage_name, parallel)
copy_uploaded_data_to_table(
conn,
cursor,
stage_name,
columns,
table_name,
database,
Expand All @@ -193,7 +195,8 @@ def write_parquet(


def copy_uploaded_data_to_table(
conn: SnowflakeConnection,
cursor: SnowflakeCursor,
stage_name: str,
columns: List[str],
table_name: str,
database: Optional[str] = None,
Expand Down Expand Up @@ -230,9 +233,6 @@ def copy_uploaded_data_to_table(
+ (table_name)
)

cursor: SnowflakeCursor = conn.cursor()
stage_name = create_temporary_sfc_stage(cursor)

if quote_identifiers:
quoted_columns = '"' + '","'.join(columns) + '"'
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
SavedDatasetSnowflakeStorage,
SnowflakeLoggingDestination,
)
from feast.infra.utils.snowflake_utils import (
copy_uploaded_data_to_table,
get_snowflake_conn,
)
from feast.infra.utils.snowflake_utils import get_snowflake_conn, write_pandas
from feast.repo_config import FeastConfigBaseModel
from tests.integration.feature_repos.universal.data_source_creator import (
DataSourceCreator,
Expand Down Expand Up @@ -53,9 +50,7 @@ def create_data_source(

destination_name = self.get_prefixed_table_name(destination_name)

copy_uploaded_data_to_table(
snowflake_conn, df, destination_name, auto_create_table=True
)
write_pandas(snowflake_conn, df, destination_name, auto_create_table=True)

self.tables.append(destination_name)

Expand Down