From 9a4497ec6028521e78f3a4506683aefbb922144e Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Fri, 18 Nov 2022 09:15:10 +0100 Subject: [PATCH] Improve insert row filter violation message grammar --- .../java/io/trino/sql/planner/LogicalPlanner.java | 2 +- .../java/io/trino/sql/query/TestRowFilter.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java index 953ec8e4c3e7..24673e9fc04d 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java @@ -489,7 +489,7 @@ private RelationPlan getInsertPlan( plan = planner.addRowFilters( table, plan, - failIfPredicateIsNotMet(metadata, session, PERMISSION_DENIED, AccessDeniedException.PREFIX + "Cannot insert row that does not match to a row filter"), + failIfPredicateIsNotMet(metadata, session, PERMISSION_DENIED, AccessDeniedException.PREFIX + "Cannot insert row that does not match a row filter"), node -> { Scope accessControlScope = analysis.getAccessControlScope(table); // hidden fields are not accessible in insert diff --git a/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java b/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java index 55007f153a48..fc0d05527dd2 100644 --- a/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java +++ b/core/trino-main/src/test/java/io/trino/sql/query/TestRowFilter.java @@ -613,15 +613,15 @@ public void testInsert() // Outside allowed row filter assertThatThrownBy(() -> assertions.query("INSERT INTO mock.tiny.nation VALUES (26, 'POLAND', 0, 'No comment')")) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); assertThatThrownBy(() -> assertions.query("INSERT INTO mock.tiny.nation VALUES " + "(26, 'POLAND', 0, 'No comment')," + "(27, 'HOLLAND', 0, 'A comment')")) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); assertThatThrownBy(() -> assertions.query("INSERT INTO mock.tiny.nation(nationkey) VALUES (null)")) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); assertThatThrownBy(() -> assertions.query("INSERT INTO mock.tiny.nation(regionkey) VALUES (0)")) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); } /** @@ -677,7 +677,7 @@ public void testRowFilterWithHiddenColumns() .matches("VALUES (BIGINT '0', 'ALGERIA', BIGINT '0', ' haggle. carefully final deposits detect slyly agai')"); assertThatThrownBy(() -> assertions.query("INSERT INTO mock.tiny.nation_with_hidden_column VALUES (101, 'POLAND', 0, 'No comment')")) .isInstanceOf(TrinoException.class) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); assertions.query("INSERT INTO mock.tiny.nation_with_hidden_column VALUES (0, 'POLAND', 0, 'No comment')") .assertThat() .skippingTypesCheck() @@ -738,10 +738,10 @@ public void testRowFilterOnOptionalColumn() assertThatThrownBy(() -> assertions.query("INSERT INTO mockmissingcolumns.tiny.nation_with_optional_column(nationkey, name, regionkey, comment, optional) VALUES (0, 'POLAND', 0, 'No comment', 'so')")) .isInstanceOf(TrinoException.class) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); assertThatThrownBy(() -> assertions.query("INSERT INTO mockmissingcolumns.tiny.nation_with_optional_column(nationkey, name, regionkey, comment, optional) VALUES (0, 'POLAND', 0, 'No comment', null)")) .isInstanceOf(TrinoException.class) - .hasMessage("Access Denied: Cannot insert row that does not match to a row filter"); + .hasMessage("Access Denied: Cannot insert row that does not match a row filter"); } }