From a70f20c441bd15cce7d0504b5695f370e9c248d4 Mon Sep 17 00:00:00 2001
From: Varnika Budati <varnika.budati@snowflake.com>
Date: Mon, 16 Sep 2024 15:53:32 -0700
Subject: [PATCH] update comments and changelog to specifically mention inplace
 updates of parents

---
 CHANGELOG.md                                            | 2 +-
 src/snowflake/snowpark/modin/plugin/extensions/index.py | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a0b07f3ae9..e209de62e7a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@
 
 #### Bug Fixes
 
-- Fixed a bug where an `Index` object created from a `Series`/`DataFrame` incorrectly updates the `Series`/`DataFrame`'s index name when it is not supposed to.
+- Fixed a bug where an `Index` object created from a `Series`/`DataFrame` incorrectly updates the `Series`/`DataFrame`'s index name after an inplace update has been applied to the original `Series`/`DataFrame`.
 
 
 ## 1.22.1 (2024-09-11)
diff --git a/src/snowflake/snowpark/modin/plugin/extensions/index.py b/src/snowflake/snowpark/modin/plugin/extensions/index.py
index 3a25d733154..cf3fed8a814 100644
--- a/src/snowflake/snowpark/modin/plugin/extensions/index.py
+++ b/src/snowflake/snowpark/modin/plugin/extensions/index.py
@@ -90,8 +90,8 @@ def __init__(self, parent: DataFrame | Series) -> None:
 
     def check_and_update_parent_qc_index_names(self, names: list) -> None:
         """
-        Update the Index and its parent's index names if the parent's current query compiler matches
-        the recorded query compiler (`_parent_qc`).
+        Update the Index and its parent's index names if the query compiler associated with the parent is
+        different from the original query compiler recorded, i.e., an inplace update has been applied to the parent.
         """
         if self._parent._query_compiler is self._parent_qc:
             new_query_compiler = self._parent_qc.set_index_names(names)
@@ -760,8 +760,9 @@ def name(self, value: Hashable) -> None:
         if not is_hashable(value):
             raise TypeError(f"{type(self).__name__}.name must be a hashable type")
         self._query_compiler = self._query_compiler.set_index_names([value])
-        # Update the name of the parent's index only if the parent's current query compiler
-        # matches the recorded query compiler.
+        # Update the name of the parent's index only if an inplace update is performed on
+        # the parent object, i.e., the parent's current query compiler matches the originally
+        # recorded query compiler.
         if self._parent is not None:
             self._parent.check_and_update_parent_qc_index_names([value])