diff --git a/src/snowflake/snowpark/_internal/analyzer/select_statement.py b/src/snowflake/snowpark/_internal/analyzer/select_statement.py index c5c63d7a9a9..8d16598152f 100644 --- a/src/snowflake/snowpark/_internal/analyzer/select_statement.py +++ b/src/snowflake/snowpark/_internal/analyzer/select_statement.py @@ -257,7 +257,7 @@ def encoded_id(self) -> str: return encode_id(type(self).__name__, self.sql_query, self.query_params) @cached_property - def encoded_query_id(self) -> str: + def encoded_query_id(self) -> Optional[str]: """Returns the id of the queries for this Selectable logical plan.""" return encoded_query_id(self.sql_query, self.query_params) @@ -509,7 +509,7 @@ def encoded_id(self) -> str: return encode_id(type(self).__name__, self.original_sql, self.query_params) @cached_property - def encoded_query_id(self) -> str: + def encoded_query_id(self) -> Optional[str]: """ Returns the id of this SelectSQL logical plan. The original SQL is used to encode its ID, which might be a non-select SQL. @@ -594,7 +594,7 @@ def placeholder_query(self) -> Optional[str]: return self._snowflake_plan.placeholder_query @cached_property - def encoded_query_id(self) -> str: + def encoded_query_id(self) -> Optional[str]: return self._snowflake_plan.encoded_query_id @property diff --git a/tests/unit/compiler/test_replace_child_and_update_node.py b/tests/unit/compiler/test_replace_child_and_update_node.py index 05098165a1b..76c3a0fec4e 100644 --- a/tests/unit/compiler/test_replace_child_and_update_node.py +++ b/tests/unit/compiler/test_replace_child_and_update_node.py @@ -441,7 +441,7 @@ def test_select_statement( assert_precondition(plan, new_plan, mock_query_generator, using_deep_copy=True) plan = copy.deepcopy(plan) - replace_child(plan, from_, new_plan, mock_query_generator) + replace_child(plan, plan.children_plan_nodes[0], new_plan, mock_query_generator) assert len(plan.children_plan_nodes) == 1 new_replaced_plan = plan.children_plan_nodes[0] @@ -566,11 +566,11 @@ def test_set_statement( assert_precondition(plan, new_plan, mock_analyzer, using_deep_copy=True) plan = copy.deepcopy(plan) - replace_child(plan, selectable1, new_plan, mock_query_generator) + replace_child(plan, plan.children_plan_nodes[0], new_plan, mock_query_generator) assert len(plan.children_plan_nodes) == 2 new_replaced_plan = plan.children_plan_nodes[0] - assert isinstance(new_replaced_plan, SelectSnowflakePlan) - assert plan.children_plan_nodes[1] == selectable2 + assert isinstance(plan.children_plan_nodes[0], SelectSnowflakePlan) + assert isinstance(plan.children_plan_nodes[1], SelectSQL) mocked_snowflake_plan = mock_snowflake_plan() verify_snowflake_plan(new_replaced_plan.snowflake_plan, mocked_snowflake_plan) diff --git a/tests/unit/test_cte.py b/tests/unit/test_cte.py index bab9d5680b3..66f41c8b5dd 100644 --- a/tests/unit/test_cte.py +++ b/tests/unit/test_cte.py @@ -13,7 +13,7 @@ def test_case1(): nodes = [mock.create_autospec(SnowflakePlan) for _ in range(7)] for i, node in enumerate(nodes): - node._id = i + node.encoded_id = i node.source_plan = None nodes[0].children_plan_nodes = [nodes[1], nodes[3]] nodes[1].children_plan_nodes = [nodes[2], nodes[2]] @@ -30,7 +30,7 @@ def test_case1(): def test_case2(): nodes = [mock.create_autospec(SnowflakePlan) for _ in range(7)] for i, node in enumerate(nodes): - node._id = i + node.encoded_id = i node.source_plan = None nodes[0].children_plan_nodes = [nodes[1], nodes[3]] nodes[1].children_plan_nodes = [nodes[2], nodes[2]] @@ -47,5 +47,5 @@ def test_case2(): @pytest.mark.parametrize("test_case", [test_case1(), test_case2()]) def test_find_duplicate_subtrees(test_case): plan, expected_duplicate_subtree_ids = test_case - duplicate_subtrees, _ = find_duplicate_subtrees(plan) - assert {node._id for node in duplicate_subtrees} == expected_duplicate_subtree_ids + duplicate_subtrees_ids = find_duplicate_subtrees(plan) + assert duplicate_subtrees_ids == expected_duplicate_subtree_ids