ClickHouse / clickhouse-academy

ClickHouse Academy training and certification
Other
18 stars 2 forks source link

TTL using now() is not supported #4

Open rfraposa opened 2 months ago

rfraposa commented 2 months ago

Module 11 uses TTL now() + INTERVAL 1 MONTH. It's not a trivial fix because it's in the recording, so maybe we add a comment or something to state it's not supported anymore.

Screenshot 2024-05-01 at 11 45 51 Screenshot 2024-05-01 at 11 45 31

pmusa commented 2 months ago

Interesting. This is the change log from Dec 23rd.

Fix check for non-deterministic functions in TTL expressions. Previously, you could create a TTL expression with non-deterministic functions in some cases, which could lead to undefined behavior later. This fixes #37250. Disallow TTL expressions that don't depend on any columns of a table by default. It can be allowed back by SET allow_suspicious_ttl_expressions = 1 or SET compatibility = '23.11'. Closes #37286. #51858 (Alexey Milovidov).

One solution is to have the following in the example:

CREATE OR REPLACE TABLE ttl_demo_1 (
    id Int,
    message String,
    now Date default now()
)
ENGINE = MergeTree
ORDER BY id
TTL now + INTERVAL 1 MONTH;

It is not the best example, as naming something now is not great, but your text would be fine.

rfraposa commented 2 months ago

Good solution. Just name the column timestamp to avoid any confusion with "now".

pmusa commented 2 months ago

but then you comment about now, does not make sense :/