Skip to content

Commit 1ceb102

Browse files
authored
Merge pull request #276 Fixed set keep_in_cache algorithm
2 parents ee57513 + 9e46a53 commit 1ceb102

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Fixed set keep_in_cache algorithm
2+
13
## 2.13.4 ##
24
* fixed sqlalchemy get_columns method with not null columns
35

ydb/_tx_ctx_impl.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def execute_request_factory(
121121
):
122122
data_query, query_id = session_state.lookup(query)
123123
parameters_types = {}
124-
keep_in_cache = False
124+
125125
if query_id is not None:
126126
query_pb = _apis.ydb_table.Query(id=query_id)
127127
parameters_types = data_query.parameters_types
@@ -131,12 +131,6 @@ def execute_request_factory(
131131
yql_text = data_query.yql_text
132132
parameters_types = data_query.parameters_types
133133
elif isinstance(query, types.DataQuery):
134-
if settings is not None and hasattr(settings, "keep_in_cache"):
135-
keep_in_cache = settings.keep_in_cache
136-
else:
137-
# that is an instance of a data query and we don't know query id for id.
138-
# so let's prepare it to keep in cache
139-
keep_in_cache = True
140134
yql_text = query.yql_text
141135
parameters_types = query.parameters_types
142136
else:
@@ -145,6 +139,17 @@ def execute_request_factory(
145139
request = _apis.ydb_table.ExecuteDataQueryRequest(
146140
parameters=convert.parameters_to_pb(parameters_types, parameters)
147141
)
142+
143+
if query_id is not None:
144+
# SDK not send query text and nothing save to cache
145+
keep_in_cache = False
146+
elif settings is not None and hasattr(settings, "keep_in_cache"):
147+
keep_in_cache = settings.keep_in_cache
148+
elif parameters:
149+
keep_in_cache = True
150+
else:
151+
keep_in_cache = False
152+
148153
if keep_in_cache:
149154
request.query_cache_policy.keep_in_cache = True
150155
request.query.MergeFrom(query_pb)

0 commit comments

Comments
 (0)