Problem: Created User with role and row policies do not see data from all shards unless default user is granted the same row policies. Setup is the following: I have clickhouse cluster, 3 shards(2 replicas each shard).
<access_management>1</access_management>
is turned on to enable user creation. Embedded click-house keeper is enabled.
CREATE USER admin_user GRANTEES ANY ON CLUSTER '{cluster}' IDENTIFIED WITH plaintext_password BY 'admin';
CREATE ROLE admin_role ON CLUSTER '{cluster}';
GRANT admin_role TO admin_user ON cluster '{cluster}';
GRANT ON CLUSTER '{cluster}' SELECT ON testdb.* TO admin_role;
CREATE ROW POLICY IF NOT EXISTS
admin_rp_local_table ON CLUSTER '{cluster}' ON testdb.local_table
USING 1 TO admin_role;
CREATE ROW POLICY IF NOT EXISTS
admin_rp_distributed_table ON CLUSTER '{cluster}' ON testdb.distributed_table
USING 1 TO admin_role;
Is executed to create user,role and row policy.
After inserting data into distributed table and trying to select it from distributed table as admin user I get result from one shard(current).
I gave row policies to default user and admin user starts to see data from all shards.
CREATE ROW POLICY IF NOT EXISTS
default_rp_local_table ON CLUSTER '{cluster}' ON testdb.local_table
USING 1 to default;
CREATE ROW POLICY IF NOT EXISTS
default_rp_distributed_table ON CLUSTER '{cluster}' ON testdb.distributed_table
USING 1 to default;
Why granting row policies to default user affects shards visibility of admin user in a cluster? (Data from all shards will be in a result set)
Added example of the situation:
We create table 'local_table' with columns id, name. Created distributed_table from local_table. Insert following data via distributed_table: (1:Bob),(2:Fred),(3:Greg). First shard local table has (1:Bob). Second shard local table has (2:Fred). Third shard local table has (3:Greg).
Added admin_role, added admin_user, granted select for admin_user. Now default and admin_user see data - (1:Bob),(2:Fred),(3:Greg) when selected from distributed table.
If we add row policy to admin_user now and make select from distributed table: default sees no data(expected, local and distributed) and admin sees only - (1:Bob) (data from local table but should see data from all shards).
if now we add the same row policy but for DEFAULT user: default see (1:Bob),(2:Fred),(3:Greg) admin see (1:Bob),(2:Fred),(3:Greg). Why so? is it a bug?