Skip to content

Conversation

@LuckySting
Copy link
Contributor

@LuckySting LuckySting commented May 12, 2024

Problem

The ydb.DataQuery is cached within a session scope using a hash of sql text as key. This lead to issues if a query is executed with different types (optional/required). For example, this code snipped reproduces the error:

with connection_no_trans.begin() as transaction:
    connection_no_trans.execute(sa.insert(table).values([{"id": 1, "text": "foo"}]))
    connection_no_trans.execute(sa.insert(table).values([{"id": 2, "text": None}]))

The "text" parameter in the first execution has type Utf8 and Optional<Utf8> in the second, which leads to error.

Proposal

There is an ability to construct a cache key manually on the caller side, so it is possible to include types of parameters to it.

Result

The example query is executed without an error.

@LuckySting LuckySting force-pushed the fix/false-cache-hit-by-query-name branch from 4a4797a to e687c59 Compare May 14, 2024 16:06
@rekby rekby merged commit 2b290d7 into ydb-platform:main May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants