SNOW-1878372: Fix analyzer access across threads#2912
Conversation
|
|
||
|
|
||
| def test_select_sql_individual_node_complexity(mock_analyzer): | ||
| def test_select_sql_individual_node_complexity(mock_session, mock_analyzer): |
There was a problem hiding this comment.
What does adding mock_session do for these tests?
There was a problem hiding this comment.
that's a good question, calling mock session here sets mock_analyzer.session=mock_session.
snowpark-python/tests/unit/conftest.py
Lines 75 to 82 in 7d4b43c
this is probably not the best way to do it. open to suggestions.
|
|
||
|
|
||
| def test_encode_node_id_with_query_select_sql(mock_analyzer): | ||
| def test_encode_node_id_with_query_select_sql(mock_session, mock_analyzer): |
There was a problem hiding this comment.
same as jamison's question. Linking old response: #2912 (comment)
| assert new_replaced_plan.analyzer == mock_query_generator | ||
| # new_replaced_plan is created with QueryGenerator.to_selectable | ||
| assert new_replaced_plan.analyzer == mock_analyzer |
There was a problem hiding this comment.
is this change to pass the new "setter" check?
is mock_query_generator/mock_analyzer used in any of the test code after?
There was a problem hiding this comment.
new_replaced_plan is created by calling within QueryGenerator.to_selectable which uses self as an analyzer.
Before this change Selectable.analyzer would have returned the analyzer used to create the selectable i.e. mock_query_generator.
After this change, Selectable.analyzer will return the appropriate session.analyzer. Therefore, we need to update this test.
Co-authored-by: Jianzhun Du <68252326+sfc-gh-jdu@users.noreply.github.com>
Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-1878372
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
In this change, we make the following changes to
Selectable:_is_valid_for_replacement=True.We also update
Analyzerto initializealias_maps_to_usewith an empty dict{}instead ofNone. In single threaded-case,resolvewould initialize alias_maps_to_use to{}and then use it foranalyzebut in multithreaded-case, it is possible for one thread to callresolveand a different thread to callanalyze.