Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yzou committed Oct 14, 2024
1 parent 53e06d6 commit a6b696f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/snowflake/snowpark/_internal/analyzer/select_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/compiler/test_replace_child_and_update_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_cte.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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]]
Expand All @@ -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

0 comments on commit a6b696f

Please sign in to comment.