Skip to content

[Question] TTL expressions allow non-deterministic functions #4004

@dcelasun

Description

@dcelasun

Company or project name

CloudQuery

Describe what's wrong

This is supposed to be disallowed since ClickHouse/ClickHouse#51858, but I noticed that now() is silently allowed. So I tried reproducing it on fiddle using rand():

CREATE TABLE users (uid Int16, ts DateTime) ENGINE=MergeTree ORDER BY uid
TTL ts + INTERVAL 1 SECOND DELETE WHERE ts>0 and rand()<2147483647;
insert into users(uid, ts) values (123, now()-interval 5 second);
select * from users;
optimize table users final;
select * from users;

Run that a few times and observe that the row isn't deleted ~50% of the time. I've checked that allow_suspicious_ttl_expressions isn't enabled.

Does it reproduce on the most recent release?

Yes

How to reproduce

  • Run the above fiddle.
  • Observe that the row isn't deleted ~50% of the time.

Expected behavior

Either rand() (and now(), now64() etc.) shouldn't be allowed, or they should be explicitly supported.

Error message and/or stacktrace

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions