chproxy icon indicating copy to clipboard operation
chproxy copied to clipboard

[Feature] Handle non-deterministic queries

Open imi-sebastian-chamena opened this issue 9 months ago • 3 comments

Is your feature request related to a problem? Please describe.

Right now, using functions like now() would end up cached even though they're different queries over time CH query caching handles them via parameter query_cache_nondeterministic_function_handling, but using chproxy they can silently end up cached.

Describe the solution you'd like

I want to have an opt-in parameter to handle them specially, so one can use same client to execute both queries and have more reliable results.

I can submit a pr but want to know if this is desired or there's a suggested alternative.

Describe alternatives you've considered

Tried using CH's query cache but doing it in chproxy is better for our usecase to not overload CH

imi-sebastian-chamena avatar Jun 05 '25 20:06 imi-sebastian-chamena

The alternative I see is to use the no_cache=1 http parameter to bypass the cache in this situation.

mga-chka avatar Jun 06 '25 09:06 mga-chka

The alternative I see is to use the no_cache=1 http parameter to bypass the cache in this situation.

yep, its the way im dealing with it

the issue is that it means we need to have a wrapper of the client just to check for non-deterministic inputs in the query and then assign the param no_cache selectively

imi-sebastian-chamena avatar Jun 06 '25 11:06 imi-sebastian-chamena

for more context on why this is desired, im using python client clickhouse_connect to add a request query param, one needs to do (undocumented, but hack around):

  1. set clickhouse_connect.common.set_setting("invalid_setting_action", "send")
  2. append on each request the kwarg {"no_cache": "1"} under settings

imi-sebastian-chamena avatar Jun 06 '25 19:06 imi-sebastian-chamena