Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions src/snowflake/snowpark/_internal/proto/ast.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,7 @@ message WritePandas {
bool auto_create_table = 1;
google.protobuf.Int64Value chunk_size = 2;
string compression = 3;
// Deprecated: use table_type instead.
bool create_temp_table = 4;
DataframeData df = 5;
repeated Tuple_String_Expr kwargs = 6;
Expand Down Expand Up @@ -2869,6 +2870,7 @@ message WriteTable {
string column_order = 4;
google.protobuf.StringValue comment = 5;
bool copy_grants = 6;
// Deprecated: use table_type instead.
bool create_temp_table = 7;
google.protobuf.Int64Value data_retention_time = 8;
google.protobuf.BoolValue enable_schema_evolution = 9;
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6512,7 +6512,7 @@ def cache_result(
ast_id = self._ast_id
self._ast_id = None # set the AST ID to None to prevent AST emission.
self.write.save_as_table(
temp_table_name, create_temp_table=True, _emit_ast=False
temp_table_name, table_type="temp", _emit_ast=False
)
self._ast_id = ast_id # restore the original AST ID.
else:
Expand Down
17 changes: 8 additions & 9 deletions src/snowflake/snowpark/dataframe_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,14 @@ def save_as_table(
statement_params = track_data_source_statement_params(
self._dataframe, statement_params or self._dataframe._statement_params
)
if create_temp_table:
warning(
"save_as_table.create_temp_table",
"create_temp_table is deprecated. We still respect this parameter when it is True but "
'please consider using `table_type="temporary"` instead.',
)
table_type = "temporary"

if _emit_ast and self._ast is not None:
# Add an Bind node that applies WriteTable() to the input, followed by its Eval.
stmt = self._dataframe._session._ast_batch.bind()
Expand Down Expand Up @@ -417,7 +425,6 @@ def save_as_table(

if column_order is not None:
expr.column_order = column_order
expr.create_temp_table = create_temp_table
expr.table_type = table_type

if clustering_keys is not None:
Expand Down Expand Up @@ -496,14 +503,6 @@ def save_as_table(
else []
)

if create_temp_table:
warning(
"save_as_table.create_temp_table",
"create_temp_table is deprecated. We still respect this parameter when it is True but "
'please consider using `table_type="temporary"` instead.',
)
table_type = "temporary"

if table_type and table_type.lower() not in SUPPORTED_TABLE_TYPES:
raise ValueError(
f"Unsupported table type. Expected table types: {SUPPORTED_TABLE_TYPES}"
Expand Down
1 change: 0 additions & 1 deletion src/snowflake/snowpark/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3649,7 +3649,6 @@ def write_pandas(
if chunk_size is not None and chunk_size != WRITE_PANDAS_CHUNK_SIZE:
ast.chunk_size.value = chunk_size
ast.compression = compression
ast.create_temp_table = create_temp_table
if isinstance(df, pandas.DataFrame):
build_table_name(
ast.df.dataframe_data__pandas.v.temp_table, table.table_name
Expand Down
3 changes: 1 addition & 2 deletions tests/ast/data/session_write_pandas.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ans2 = session.write_pandas(df, "test", schema="a", database="b", chunk_size=7,

ans = session.write_pandas(pandas.DataFrame(<not shown>), "table1")

ans2 = session.write_pandas(pandas.DataFrame(<not shown>), "test", database="b", schema="a", chunk_size=7, compression="brotli", on_error="ignore", parallel=10, quote_identifiers=False, auto_create_table=True, create_temp_table=True, overwrite=True, table_type="temporary", random=90)
ans2 = session.write_pandas(pandas.DataFrame(<not shown>), "test", database="b", schema="a", chunk_size=7, compression="brotli", on_error="ignore", parallel=10, quote_identifiers=False, auto_create_table=True, overwrite=True, table_type="temporary", random=90)

## EXPECTED ENCODED AST

Expand Down Expand Up @@ -78,7 +78,6 @@ body {
value: 7
}
compression: "brotli"
create_temp_table: true
df {
dataframe_data__pandas {
v {
Expand Down
Loading