diff --git a/src/snowflake/snowpark/_internal/proto/ast.proto b/src/snowflake/snowpark/_internal/proto/ast.proto index fe5ad1ef4b..d33cc55d1d 100644 --- a/src/snowflake/snowpark/_internal/proto/ast.proto +++ b/src/snowflake/snowpark/_internal/proto/ast.proto @@ -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; @@ -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; diff --git a/src/snowflake/snowpark/dataframe.py b/src/snowflake/snowpark/dataframe.py index 6b0f59a1a0..42e7b4ef65 100644 --- a/src/snowflake/snowpark/dataframe.py +++ b/src/snowflake/snowpark/dataframe.py @@ -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: diff --git a/src/snowflake/snowpark/dataframe_writer.py b/src/snowflake/snowpark/dataframe_writer.py index bce50edf91..91d8fc9517 100644 --- a/src/snowflake/snowpark/dataframe_writer.py +++ b/src/snowflake/snowpark/dataframe_writer.py @@ -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() @@ -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: @@ -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}" diff --git a/src/snowflake/snowpark/session.py b/src/snowflake/snowpark/session.py index da0f4a409f..aea7b7e5de 100644 --- a/src/snowflake/snowpark/session.py +++ b/src/snowflake/snowpark/session.py @@ -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 diff --git a/tests/ast/data/session_write_pandas.test b/tests/ast/data/session_write_pandas.test index 6fd71b77ba..d2433b24d3 100644 --- a/tests/ast/data/session_write_pandas.test +++ b/tests/ast/data/session_write_pandas.test @@ -12,7 +12,7 @@ ans2 = session.write_pandas(df, "test", schema="a", database="b", chunk_size=7, ans = session.write_pandas(pandas.DataFrame(), "table1") -ans2 = session.write_pandas(pandas.DataFrame(), "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(), "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 @@ -78,7 +78,6 @@ body { value: 7 } compression: "brotli" - create_temp_table: true df { dataframe_data__pandas { v {