Skip to content
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-746341 Add file format specification to create temp stage SQL in pd_writer #1594

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion src/snowflake/connector/pandas_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def write_pandas(
name=random_string(),
quote_identifiers=quote_identifiers,
)
create_stage_sql = f"CREATE TEMP STAGE /* Python:snowflake.connector.pandas_tools.write_pandas() */ {stage_location}"
create_stage_sql = f"CREATE TEMP STAGE /* Python:snowflake.connector.pandas_tools.write_pandas() */ {stage_location} FILE_FORMAT=(TYPE=PARQUET COMPRESSION={compression_map[compression]}{' BINARY_AS_TEXT=FALSE' if auto_create_table or overwrite else ''})"
logger.debug(f"creating stage with '{create_stage_sql}'")
cursor.execute(create_stage_sql, _is_internal=True).fetchall()

Expand Down
9 changes: 9 additions & 0 deletions test/integ/pandas/test_pandas_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
)


def test_fix_snow_746341(conn_cnx: Callable[..., Generator[SnowflakeConnection, None, None]]):
cat = '"cat"'
df = pandas.DataFrame([[1], [2]], columns=[f"col_'{cat}'"])
table_name = random_string(5, "snow746341_")
with conn_cnx() as conn:
write_pandas(conn, df, table_name, auto_create_table=True, table_type="temporary")
assert conn.cursor().execute(f'select * from "{table_name}"').fetchall() == [(1,),(2,)]

sfc-gh-stan marked this conversation as resolved.
Show resolved Hide resolved

@pytest.mark.parametrize("quote_identifiers", [True, False])
@pytest.mark.parametrize("auto_create_table", [True, False])
@pytest.mark.parametrize("index", [False])
Expand Down