ClickHouse icon indicating copy to clipboard operation
ClickHouse copied to clipboard

Cached queries fails when a string parameter looks like a system table

Open mdonkers opened this issue 1 year ago • 0 comments

Company or project name

Dash0

Describe what's wrong

Whenever a query is being cached (using SETTINGS use_query_cache = true) and some string 'looks' like a system table, the query fails with the message:

Code: 719. DB::Exception: Received from localhost:9000. DB::Exception: The query result was not cached because the query contains a system table. Use setting query_cache_system_table_handling = 'save' or = 'ignore' to cache the query result regardless or to omit caching. (QUERY_CACHE_USED_WITH_SYSTEM_TABLE)

However no system table is being used. Try e.g. with:

CREATE TABLE users (uid Int16, name String, age Int16) ENGINE=Memory;

SELECT * FROM users WHERE name = 'system.metrics' SETTINGS use_query_cache = true;

Fiddle: https://fiddle.clickhouse.com/efd71f42-006d-4dff-9a2b-3445d1cf9c1f

Does it reproduce on the most recent release?

Yes, both 24.8.2 (Fiddle) and 24.6.3 (local version) affected

Enable crash reporting

How to reproduce

See the above Fiddle

Expected behavior

Caching works normally since its a 'regular' SQL statement that gets cached fine with another string value

Error message and/or stacktrace

Code: 719. DB::Exception: Received from localhost:9000. DB::Exception: The query result was not cached because the query contains a system table. Use setting query_cache_system_table_handling = 'save' or = 'ignore' to cache the query result regardless or to omit caching. (QUERY_CACHE_USED_WITH_SYSTEM_TABLE)

Additional context

mdonkers avatar Aug 28 '24 12:08 mdonkers