Skip to content

Commit

Permalink
copy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jdu committed Mar 5, 2024
1 parent e97a05a commit 6fcf71f
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/snowflake/snowpark/_internal/analyzer/snowflake_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,32 @@ def output_dict(self) -> Dict[str, Any]:
return self._output_dict

def __copy__(self) -> "SnowflakePlan":
return SnowflakePlan(
copy.deepcopy(self.queries) if self.queries else [],
self.schema_query,
copy.deepcopy(self.post_actions) if self.post_actions else None,
dict(self.expr_to_alias) if self.expr_to_alias else None,
self.source_plan,
self.is_ddl_on_temp_object,
copy.deepcopy(self.api_calls) if self.api_calls else None,
self.df_aliased_col_name_to_real_col_name,
session=self.session,
placeholder_query=self.placeholder_query,
)
if self.session._cte_optimization_enabled:
return SnowflakePlan(
copy.deepcopy(self.queries) if self.queries else [],
self.schema_query,
copy.deepcopy(self.post_actions) if self.post_actions else None,
dict(self.expr_to_alias) if self.expr_to_alias else None,
self.source_plan,
self.is_ddl_on_temp_object,
copy.deepcopy(self.api_calls) if self.api_calls else None,
self.df_aliased_col_name_to_real_col_name,
session=self.session,
placeholder_query=self.placeholder_query,
)
else:
return SnowflakePlan(
self.queries.copy() if self.queries else [],
self.schema_query,
self.post_actions.copy() if self.post_actions else None,
dict(self.expr_to_alias) if self.expr_to_alias else None,
self.source_plan,
self.is_ddl_on_temp_object,
self.api_calls.copy() if self.api_calls else None,
self.df_aliased_col_name_to_real_col_name,
session=self.session,
placeholder_query=self.placeholder_query,
)

def add_aliases(self, to_add: Dict) -> None:
self.expr_to_alias = {**self.expr_to_alias, **to_add}
Expand Down

0 comments on commit 6fcf71f

Please sign in to comment.