Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinMax projection allows to violate row policy #37454

Closed
CurtizJ opened this issue May 23, 2022 · 1 comment
Closed

MinMax projection allows to violate row policy #37454

CurtizJ opened this issue May 23, 2022 · 1 comment

Comments

@CurtizJ
Copy link
Member

CurtizJ commented May 23, 2022

Describe the unexpected behaviour
If we read from projection, row policy is disabled explicitly. It can be ok if we have added the projection explicitly (but still need to be documented), because it's unclear how to filter rows, since the row policy expression is set for original rows. But projection from minmax index is created implicitly and enabled by default and it's unexpected that it will allow to run some simple queries ignoring row policies.

How to reproduce

CREATE TABLE t(a UInt32, b UInt32) ENGINE = MergeTree PARTITION BY a ORDER BY a;

INSERT INTO t SELECT number % 10, number FROM numbers(10000);

CREATE ROW POLICY OR REPLACE rp ON default.t FOR SELECT USING 0 TO ALL;

SELECT count(), min(a), max(a) FROM t;

┌─count()─┬─min(a)─┬─max(a)─┐
│   1000009 │
└─────────┴────────┴────────┘

SELECT count(), min(a), max(a), sum(a) FROM t;

┌─count()─┬─min(a)─┬─max(a)─┬─sum(a)─┐
│       0000 │
└─────────┴────────┴────────┴────────┘


SET allow_experimental_projection_optimization = 0;

SELECT count(), min(a), max(a) FROM t;

┌─count()─┬─min(a)─┬─max(a)─┐
│       000 │
└─────────┴────────┴────────┘

Expected behavior
Do not use implicitly created projection if row policy is set.

@amosbird
Copy link
Collaborator

If we read from projection, row policy is disabled explicitly.

User defined projections support row policy properly, test

min_max_count projection is special when dealing with filters. It always uses PartitionPruner, which means related KeyCondition should be properly constructed. However, we don't support using row policy in any kind of index analysis yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants