Skip to content

Commit

Permalink
SNOW-1308650: revert breaking change and release a newer version (#1916)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aling authored Apr 8, 2024
1 parent 524eaa7 commit 86ba28a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 49 deletions.
4 changes: 4 additions & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne

# Release Notes

- v3.8.1(April 09, 2024)

- Reverted the change "Updated `write_pandas` to skip TABLE IF NOT EXISTS in truncate mode." introduced in v3.8.0 (yanked) as it's a breaking change. `write_pandas` will be fixed in the future in a non-breaking way.

- v3.8.0(April 04,2024)

- Improved `externalbrowser` auth in containerized environments
Expand Down
15 changes: 7 additions & 8 deletions src/snowflake/connector/pandas_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,13 @@ def drop_object(name: str, object_type: str) -> None:
quote_identifiers,
)

if auto_create_table:
create_table_sql = (
f"CREATE {table_type.upper()} TABLE IF NOT EXISTS {target_table_location} "
f"({create_table_columns})"
f" /* Python:snowflake.connector.pandas_tools.write_pandas() */ "
)
logger.debug(f"auto creating table with '{create_table_sql}'")
cursor.execute(create_table_sql, _is_internal=True)
create_table_sql = (
f"CREATE {table_type.upper()} TABLE IF NOT EXISTS {target_table_location} "
f"({create_table_columns})"
f" /* Python:snowflake.connector.pandas_tools.write_pandas() */ "
)
logger.debug(f"auto creating table with '{create_table_sql}'")
cursor.execute(create_table_sql, _is_internal=True)
# need explicit casting when the underlying table schema is inferred
parquet_columns = "$1:" + ",$1:".join(
f"{quote}{snowflake_col}{quote}::{column_type_mapping[col]}"
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/connector/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Update this for the versions
# Don't change the forth version number from None
VERSION = (3, 8, 0, None)
VERSION = (3, 8, 1, None)
30 changes: 0 additions & 30 deletions test/integ/pandas/test_pandas_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def test_write_pandas_with_overwrite(
f"({col_name} STRING, {col_points} INT, {col_id} INT AUTOINCREMENT)"
)

show_sql = f"SHOW TABLES LIKE '{random_table_name}'" # SHOW command like is case-insensitive
select_sql = f"SELECT * FROM {table_name}"
select_count_sql = f"SELECT count(*) FROM {table_name}"
drop_sql = f"DROP TABLE IF EXISTS {table_name}"
Expand Down Expand Up @@ -149,35 +148,6 @@ def test_write_pandas_with_overwrite(
# Check number of rows
assert result["COUNT(*)"] == 1

# Truncate-only mode
if not auto_create_table:
# Capture the created_on timestamp of the target table before truncation
result = cnx.cursor(DictCursor).execute(show_sql).fetchone()
create_ts_before_trunc = result["created_on"]

# This operation should only truncate the table
success, nchunks, nrows, _ = write_pandas(
cnx,
df2,
random_table_name,
quote_identifiers=quote_identifiers,
auto_create_table=auto_create_table,
overwrite=True,
index=index,
)

# Capture the created_on timestamp of the target table after truncation
result = cnx.cursor(DictCursor).execute(show_sql).fetchone()
create_ts_after_trunc = result["created_on"]
assert create_ts_before_trunc == create_ts_after_trunc

# Check write_pandas output
assert success
assert nchunks == 1
result = cnx.cursor(DictCursor).execute(select_count_sql).fetchone()
# Check number of rows
assert result["COUNT(*)"] == 1

# Write dataframe with a different schema
if auto_create_table:
# Should drop table and SUCCEED because the new table will be created with new schema of df3
Expand Down
4 changes: 2 additions & 2 deletions tested_requirements/requirements_310.reqs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ pytz==2024.1
requests==2.31.0
sortedcontainers==2.4.0
tomlkit==0.12.4
typing_extensions==4.10.0
typing_extensions==4.11.0
urllib3==2.2.1
snowflake-connector-python==3.8.0
snowflake-connector-python==3.8.1
4 changes: 2 additions & 2 deletions tested_requirements/requirements_311.reqs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ pytz==2024.1
requests==2.31.0
sortedcontainers==2.4.0
tomlkit==0.12.4
typing_extensions==4.10.0
typing_extensions==4.11.0
urllib3==2.2.1
snowflake-connector-python==3.8.0
snowflake-connector-python==3.8.1
4 changes: 2 additions & 2 deletions tested_requirements/requirements_312.reqs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ requests==2.31.0
setuptools==69.2.0
sortedcontainers==2.4.0
tomlkit==0.12.4
typing_extensions==4.10.0
typing_extensions==4.11.0
urllib3==2.2.1
wheel==0.43.0
snowflake-connector-python==3.8.0
snowflake-connector-python==3.8.1
4 changes: 2 additions & 2 deletions tested_requirements/requirements_38.reqs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ pytz==2024.1
requests==2.31.0
sortedcontainers==2.4.0
tomlkit==0.12.4
typing_extensions==4.10.0
typing_extensions==4.11.0
urllib3==1.26.18
snowflake-connector-python==3.8.0
snowflake-connector-python==3.8.1
4 changes: 2 additions & 2 deletions tested_requirements/requirements_39.reqs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ pytz==2024.1
requests==2.31.0
sortedcontainers==2.4.0
tomlkit==0.12.4
typing_extensions==4.10.0
typing_extensions==4.11.0
urllib3==1.26.18
snowflake-connector-python==3.8.0
snowflake-connector-python==3.8.1

0 comments on commit 86ba28a

Please sign in to comment.