["another ON mydb.filtered_table1","another","mydb","filtered_table1","6068883a-0e9d-f802-7e22-0144f8e66d3c","users.xml","1",0,0,"['another']","[]"],
["another ON mydb.filtered_table2","another","mydb","filtered_table2","c019e957-c60b-d54e-cc52-7c90dac5fb01","users.xml","1",0,0,"['another']","[]"],
["another ON mydb.filtered_table3","another","mydb","filtered_table3","4cb080d0-44e8-dbef-6026-346655143628","users.xml","1",0,0,"['another']","[]"],
["another ON mydb.local","another","mydb","local","5b23c389-7e18-06bf-a6bc-dd1afbbc0a97","users.xml","a = 1",0,0,"['another']","[]"],
["default ON mydb.filtered_table1","default","mydb","filtered_table1","9e8a8f62-4965-2b5e-8599-57c7b99b3549","users.xml","a = 1",0,0,"['default']","[]"],
["default ON mydb.filtered_table2","default","mydb","filtered_table2","cffae79d-b9bf-a2ef-b798-019c18470b25","users.xml","a + b < 1 or c - d > 5",0,0,"['default']","[]"],
["default ON mydb.filtered_table3","default","mydb","filtered_table3","12fc5cef-e3da-3940-ec79-d8be3911f42b","users.xml","c = 1",0,0,"['default']","[]"],
["default ON mydb.local","default","mydb","local","cdacaeb5-1d97-f99d-2bb0-4574f290629c","users.xml","1",0,0,"['default']","[]"]
]
assertnode.query("SELECT * from system.row_policies ORDER BY short_name, database, table")==TSV(policies)
assertnode.query("SHOW POLICIES")==TSV(["another ON mydb.filtered_table1","another ON mydb.filtered_table2","another ON mydb.filtered_table3","another ON mydb.local","default ON mydb.filtered_table1","default ON mydb.filtered_table2","default ON mydb.filtered_table3","default ON mydb.local"])
assertnode.query("SHOW POLICIES ON mydb.filtered_table1")==TSV(["another","default"])
assertnode.query("SHOW POLICIES ON mydb.local")==TSV(["another","default"])
assertnode.query("SHOW POLICIES ON mydb.*")==TSV(["another ON mydb.filtered_table1","another ON mydb.filtered_table2","another ON mydb.filtered_table3","another ON mydb.local","default ON mydb.filtered_table1","default ON mydb.filtered_table2","default ON mydb.filtered_table3","default ON mydb.local"])
assertnode.query("SHOW POLICIES default")==TSV(["default ON mydb.filtered_table1","default ON mydb.filtered_table2","default ON mydb.filtered_table3","default ON mydb.local"])
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table1")=="CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table2")=="CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING ((a + b) < 1) OR ((c - d) > 5) TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table3")=="CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING c = 1 TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.local")=="CREATE ROW POLICY default ON mydb.local FOR SELECT USING 1 TO default\n"
assertnode.query("SHOW CREATE POLICY default")==TSV(["CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default","CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING ((a + b) < 1) OR ((c - d) > 5) TO default","CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING c = 1 TO default","CREATE ROW POLICY default ON mydb.local FOR SELECT USING 1 TO default"])
assertnode.query("SHOW CREATE POLICIES ON mydb.filtered_table1")==TSV(["CREATE ROW POLICY another ON mydb.filtered_table1 FOR SELECT USING 1 TO another","CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default"])
assertnode.query("SHOW CREATE POLICIES ON mydb.*")==TSV(["CREATE ROW POLICY another ON mydb.filtered_table1 FOR SELECT USING 1 TO another","CREATE ROW POLICY another ON mydb.filtered_table2 FOR SELECT USING 1 TO another","CREATE ROW POLICY another ON mydb.filtered_table3 FOR SELECT USING 1 TO another","CREATE ROW POLICY another ON mydb.local FOR SELECT USING a = 1 TO another","CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default","CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING ((a + b) < 1) OR ((c - d) > 5) TO default","CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING c = 1 TO default","CREATE ROW POLICY default ON mydb.local FOR SELECT USING 1 TO default"])
assertnode.query("SHOW CREATE POLICIES")==TSV(["CREATE ROW POLICY another ON mydb.filtered_table1 FOR SELECT USING 1 TO another","CREATE ROW POLICY another ON mydb.filtered_table2 FOR SELECT USING 1 TO another","CREATE ROW POLICY another ON mydb.filtered_table3 FOR SELECT USING 1 TO another","CREATE ROW POLICY another ON mydb.local FOR SELECT USING a = 1 TO another","CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING a = 1 TO default","CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING ((a + b) < 1) OR ((c - d) > 5) TO default","CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING c = 1 TO default","CREATE ROW POLICY default ON mydb.local FOR SELECT USING 1 TO default"])
assertnode.query("SHOW POLICIES")==TSV(["another ON mydb.filtered_table1","another ON mydb.filtered_table2","another ON mydb.filtered_table3","default ON mydb.filtered_table1","default ON mydb.filtered_table2","default ON mydb.filtered_table3"])
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table1")=="CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING 1 TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table2")=="CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING 1 TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table3")=="CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING 1 TO default\n"
assertnode.query("SHOW POLICIES")==TSV(["another ON mydb.filtered_table1","another ON mydb.filtered_table2","another ON mydb.filtered_table3","default ON mydb.filtered_table1","default ON mydb.filtered_table2","default ON mydb.filtered_table3"])
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table1")=="CREATE ROW POLICY default ON mydb.filtered_table1 FOR SELECT USING NULL TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table2")=="CREATE ROW POLICY default ON mydb.filtered_table2 FOR SELECT USING NULL TO default\n"
assertnode.query("SHOW CREATE POLICY default ON mydb.filtered_table3")=="CREATE ROW POLICY default ON mydb.filtered_table3 FOR SELECT USING NULL TO default\n"
node.query("CREATE TABLE mydb.filtered_table1 (a UInt8, b UInt8) ENGINE ReplicatedMergeTree('/clickhouse/tables/00-00/filtered_table1', 'replica1') ORDER BY a")
node.query("CREATE TABLE mydb.filtered_table1 (a UInt8, b Int8) ENGINE ReplicatedCollapsingMergeTree('/clickhouse/tables/00-00/filtered_table1', 'replica1', b) ORDER BY a")