From ac8d2d472201eef7c9a3129bd72835f57f2c3faa Mon Sep 17 00:00:00 2001 From: Krzysztof Sobolewski Date: Mon, 27 Jun 2022 12:56:11 +0200 Subject: [PATCH] Remove obsolete row filter and column mask methods The current deprecation policy, introduced around the time these methods were deprecated, is that we promise to keep deprecated methods for one more release. According to this, removal is long overdue. --- .../TestInjectedConnectorAccessControl.java | 8 +---- .../spi/connector/ConnectorAccessControl.java | 29 ---------------- .../spi/security/SystemAccessControl.java | 33 ++----------------- .../ForwardingConnectorAccessControl.java | 12 ------- .../ForwardingSystemAccessControl.java | 12 ------- .../TestClassLoaderSafeWrappers.java | 8 +---- .../security/TestAllowAllAccessControl.java | 8 +---- .../TestAllowAllSystemAccessControl.java | 8 +---- .../security/TestFileBasedAccessControl.java | 5 +-- .../TestFileBasedSystemAccessControl.java | 3 -- .../security/TestLegacyAccessControl.java | 8 +---- .../TestSqlStandardAccessControl.java | 8 +---- 12 files changed, 9 insertions(+), 133 deletions(-) diff --git a/core/trino-main/src/test/java/io/trino/security/TestInjectedConnectorAccessControl.java b/core/trino-main/src/test/java/io/trino/security/TestInjectedConnectorAccessControl.java index 3e2e0c0bc626..3ad21b949b18 100644 --- a/core/trino-main/src/test/java/io/trino/security/TestInjectedConnectorAccessControl.java +++ b/core/trino-main/src/test/java/io/trino/security/TestInjectedConnectorAccessControl.java @@ -13,11 +13,7 @@ */ package io.trino.security; -import com.google.common.collect.ImmutableSet; import io.trino.spi.connector.ConnectorAccessControl; -import io.trino.spi.connector.ConnectorSecurityContext; -import io.trino.spi.connector.SchemaTableName; -import io.trino.spi.type.Type; import org.testng.annotations.Test; import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden; @@ -28,8 +24,6 @@ public class TestInjectedConnectorAccessControl public void testEverythingImplemented() throws NoSuchMethodException { - assertAllMethodsOverridden(ConnectorAccessControl.class, InjectedConnectorAccessControl.class, ImmutableSet.of( - InjectedConnectorAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class), - InjectedConnectorAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class))); + assertAllMethodsOverridden(ConnectorAccessControl.class, InjectedConnectorAccessControl.class); } } diff --git a/core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorAccessControl.java b/core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorAccessControl.java index d115bf640db1..e1d8b20e359d 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorAccessControl.java +++ b/core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorAccessControl.java @@ -608,20 +608,6 @@ default void checkCanExecuteFunction(ConnectorSecurityContext context, FunctionK denyExecuteFunction(function.toString()); } - /** - * Get a row filter associated with the given table and identity. - *

- * The filter must be a scalar SQL expression of boolean type over the columns in the table. - * - * @return the filter, or {@link Optional#empty()} if not applicable - * @deprecated use {@link #getRowFilters(ConnectorSecurityContext, SchemaTableName)} instead - */ - @Deprecated - default Optional getRowFilter(ConnectorSecurityContext context, SchemaTableName tableName) - { - return Optional.empty(); - } - /** * Get row filters associated with the given table and identity. *

@@ -634,21 +620,6 @@ default List getRowFilters(ConnectorSecurityContext context, Sch return emptyList(); } - /** - * Get a column mask associated with the given table, column and identity. - *

- * The mask must be a scalar SQL expression of a type coercible to the type of the column being masked. The expression - * must be written in terms of columns in the table. - * - * @return the mask, or {@link Optional#empty()} if not applicable - * @deprecated use {@link #getColumnMasks(ConnectorSecurityContext, SchemaTableName, String, Type)} instead - */ - @Deprecated - default Optional getColumnMask(ConnectorSecurityContext context, SchemaTableName tableName, String columnName, Type type) - { - return Optional.empty(); - } - /** * Get column masks associated with the given table, column and identity. *

diff --git a/core/trino-spi/src/main/java/io/trino/spi/security/SystemAccessControl.java b/core/trino-spi/src/main/java/io/trino/spi/security/SystemAccessControl.java index 4717fce8b7f5..650f44c3e316 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/security/SystemAccessControl.java +++ b/core/trino-spi/src/main/java/io/trino/spi/security/SystemAccessControl.java @@ -829,20 +829,6 @@ default void checkCanExecuteTableProcedure(SystemSecurityContext systemSecurityC denyExecuteTableProcedure(table.toString(), procedure); } - /** - * Get a row filter associated with the given table and identity. - *

- * The filter must be a scalar SQL expression of boolean type over the columns in the table. - * - * @return the filter, or {@link Optional#empty()} if not applicable - * @deprecated use {@link #getRowFilters(SystemSecurityContext, CatalogSchemaTableName)} instead - */ - @Deprecated - default Optional getRowFilter(SystemSecurityContext context, CatalogSchemaTableName tableName) - { - return Optional.empty(); - } - /** * Get row filters associated with the given table and identity. *

@@ -852,22 +838,7 @@ default Optional getRowFilter(SystemSecurityContext context, Cat */ default List getRowFilters(SystemSecurityContext context, CatalogSchemaTableName tableName) { - return getRowFilter(context, tableName).map(List::of).orElseGet(List::of); - } - - /** - * Get a column mask associated with the given table, column and identity. - *

- * The mask must be a scalar SQL expression of a type coercible to the type of the column being masked. The expression - * must be written in terms of columns in the table. - * - * @return the mask, or {@link Optional#empty()} if not applicable - * @deprecated use {@link #getColumnMasks(SystemSecurityContext, CatalogSchemaTableName, String, Type)} instead - */ - @Deprecated - default Optional getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) - { - return Optional.empty(); + return List.of(); } /** @@ -880,7 +851,7 @@ default Optional getColumnMask(SystemSecurityContext context, Ca */ default List getColumnMasks(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) { - return getColumnMask(context, tableName, columnName, type).map(List::of).orElseGet(List::of); + return List.of(); } /** diff --git a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingConnectorAccessControl.java b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingConnectorAccessControl.java index a7c80840f2d2..74702e9ba44e 100644 --- a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingConnectorAccessControl.java +++ b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingConnectorAccessControl.java @@ -393,24 +393,12 @@ public void checkCanExecuteFunction(ConnectorSecurityContext context, FunctionKi delegate().checkCanExecuteFunction(context, functionKind, function); } - @Override - public Optional getRowFilter(ConnectorSecurityContext context, SchemaTableName tableName) - { - return delegate().getRowFilter(context, tableName); - } - @Override public List getRowFilters(ConnectorSecurityContext context, SchemaTableName tableName) { return delegate().getRowFilters(context, tableName); } - @Override - public Optional getColumnMask(ConnectorSecurityContext context, SchemaTableName tableName, String columnName, Type type) - { - return delegate().getColumnMask(context, tableName, columnName, type); - } - @Override public List getColumnMasks(ConnectorSecurityContext context, SchemaTableName tableName, String columnName, Type type) { diff --git a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingSystemAccessControl.java b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingSystemAccessControl.java index c117804eac6e..533fa1bf4289 100644 --- a/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingSystemAccessControl.java +++ b/lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/ForwardingSystemAccessControl.java @@ -487,24 +487,12 @@ public Iterable getEventListeners() return delegate().getEventListeners(); } - @Override - public Optional getRowFilter(SystemSecurityContext context, CatalogSchemaTableName tableName) - { - return delegate().getRowFilter(context, tableName); - } - @Override public List getRowFilters(SystemSecurityContext context, CatalogSchemaTableName tableName) { return delegate().getRowFilters(context, tableName); } - @Override - public Optional getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) - { - return delegate().getColumnMask(context, tableName, columnName, type); - } - @Override public List getColumnMasks(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) { diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/classloader/TestClassLoaderSafeWrappers.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/classloader/TestClassLoaderSafeWrappers.java index 7249580ca447..6f8fab41065f 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/classloader/TestClassLoaderSafeWrappers.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/classloader/TestClassLoaderSafeWrappers.java @@ -13,7 +13,6 @@ */ package io.trino.plugin.base.classloader; -import com.google.common.collect.ImmutableSet; import io.trino.spi.connector.ConnectorAccessControl; import io.trino.spi.connector.ConnectorMetadata; import io.trino.spi.connector.ConnectorNodePartitioningProvider; @@ -21,15 +20,12 @@ import io.trino.spi.connector.ConnectorPageSinkProvider; import io.trino.spi.connector.ConnectorPageSourceProvider; import io.trino.spi.connector.ConnectorRecordSetProvider; -import io.trino.spi.connector.ConnectorSecurityContext; import io.trino.spi.connector.ConnectorSplitManager; import io.trino.spi.connector.ConnectorSplitSource; import io.trino.spi.connector.RecordSet; -import io.trino.spi.connector.SchemaTableName; import io.trino.spi.connector.SystemTable; import io.trino.spi.eventlistener.EventListener; import io.trino.spi.ptf.ConnectorTableFunction; -import io.trino.spi.type.Type; import org.testng.annotations.Test; import java.lang.reflect.Method; @@ -47,9 +43,7 @@ public class TestClassLoaderSafeWrappers public void test() throws Exception { - testClassLoaderSafe(ConnectorAccessControl.class, ClassLoaderSafeConnectorAccessControl.class, ImmutableSet.of( - ClassLoaderSafeConnectorAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class), - ClassLoaderSafeConnectorAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class))); + testClassLoaderSafe(ConnectorAccessControl.class, ClassLoaderSafeConnectorAccessControl.class); testClassLoaderSafe(ConnectorMetadata.class, ClassLoaderSafeConnectorMetadata.class); testClassLoaderSafe(ConnectorPageSink.class, ClassLoaderSafeConnectorPageSink.class); testClassLoaderSafe(ConnectorPageSinkProvider.class, ClassLoaderSafeConnectorPageSinkProvider.class); diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllAccessControl.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllAccessControl.java index f53c0c0c4739..7de751d5db6f 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllAccessControl.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllAccessControl.java @@ -13,11 +13,7 @@ */ package io.trino.plugin.base.security; -import com.google.common.collect.ImmutableSet; import io.trino.spi.connector.ConnectorAccessControl; -import io.trino.spi.connector.ConnectorSecurityContext; -import io.trino.spi.connector.SchemaTableName; -import io.trino.spi.type.Type; import org.testng.annotations.Test; import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden; @@ -28,8 +24,6 @@ public class TestAllowAllAccessControl public void testEverythingImplemented() throws NoSuchMethodException { - assertAllMethodsOverridden(ConnectorAccessControl.class, AllowAllAccessControl.class, ImmutableSet.of( - AllowAllAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class), - AllowAllAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class))); + assertAllMethodsOverridden(ConnectorAccessControl.class, AllowAllAccessControl.class); } } diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllSystemAccessControl.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllSystemAccessControl.java index e7f0b2a078db..cb30228b39b4 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllSystemAccessControl.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestAllowAllSystemAccessControl.java @@ -13,11 +13,7 @@ */ package io.trino.plugin.base.security; -import com.google.common.collect.ImmutableSet; -import io.trino.spi.connector.CatalogSchemaTableName; import io.trino.spi.security.SystemAccessControl; -import io.trino.spi.security.SystemSecurityContext; -import io.trino.spi.type.Type; import org.testng.annotations.Test; import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden; @@ -28,8 +24,6 @@ public class TestAllowAllSystemAccessControl public void testEverythingImplemented() throws ReflectiveOperationException { - assertAllMethodsOverridden(SystemAccessControl.class, AllowAllSystemAccessControl.class, ImmutableSet.of( - AllowAllSystemAccessControl.class.getMethod("getRowFilter", SystemSecurityContext.class, CatalogSchemaTableName.class), - AllowAllSystemAccessControl.class.getMethod("getColumnMask", SystemSecurityContext.class, CatalogSchemaTableName.class, String.class, Type.class))); + assertAllMethodsOverridden(SystemAccessControl.class, AllowAllSystemAccessControl.class); } } diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControl.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControl.java index dd2b69a52594..16558a3bec16 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControl.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedAccessControl.java @@ -28,7 +28,6 @@ import io.trino.spi.security.Privilege; import io.trino.spi.security.TrinoPrincipal; import io.trino.spi.security.ViewExpression; -import io.trino.spi.type.Type; import org.testng.Assert.ThrowingRunnable; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -538,9 +537,7 @@ public void testSchemaRulesForCheckCanShowTables() public void testEverythingImplemented() throws NoSuchMethodException { - assertAllMethodsOverridden(ConnectorAccessControl.class, FileBasedAccessControl.class, ImmutableSet.of( - FileBasedAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class), - FileBasedAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class))); + assertAllMethodsOverridden(ConnectorAccessControl.class, FileBasedAccessControl.class); } private static ConnectorSecurityContext user(String name, Set groups) diff --git a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedSystemAccessControl.java b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedSystemAccessControl.java index 3ca60041f02b..03588492e17e 100644 --- a/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedSystemAccessControl.java +++ b/lib/trino-plugin-toolkit/src/test/java/io/trino/plugin/base/security/TestFileBasedSystemAccessControl.java @@ -29,7 +29,6 @@ import io.trino.spi.security.SystemSecurityContext; import io.trino.spi.security.TrinoPrincipal; import io.trino.spi.security.ViewExpression; -import io.trino.spi.type.Type; import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -1370,8 +1369,6 @@ public void testEverythingImplemented() throws NoSuchMethodException { assertAllMethodsOverridden(SystemAccessControl.class, FileBasedSystemAccessControl.class, ImmutableSet.of( - FileBasedSystemAccessControl.class.getMethod("getRowFilter", SystemSecurityContext.class, CatalogSchemaTableName.class), - FileBasedSystemAccessControl.class.getMethod("getColumnMask", SystemSecurityContext.class, CatalogSchemaTableName.class, String.class, Type.class), FileBasedSystemAccessControl.class.getMethod("checkCanViewQueryOwnedBy", SystemSecurityContext.class, Identity.class), FileBasedSystemAccessControl.class.getMethod("filterViewQueryOwnedBy", SystemSecurityContext.class, Collection.class), FileBasedSystemAccessControl.class.getMethod("checkCanKillQueryOwnedBy", SystemSecurityContext.class, Identity.class))); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacyAccessControl.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacyAccessControl.java index cf2081b62a11..651aab22d044 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacyAccessControl.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestLegacyAccessControl.java @@ -13,11 +13,7 @@ */ package io.trino.plugin.hive.security; -import com.google.common.collect.ImmutableSet; import io.trino.spi.connector.ConnectorAccessControl; -import io.trino.spi.connector.ConnectorSecurityContext; -import io.trino.spi.connector.SchemaTableName; -import io.trino.spi.type.Type; import org.testng.annotations.Test; import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden; @@ -28,8 +24,6 @@ public class TestLegacyAccessControl public void testEverythingImplemented() throws NoSuchMethodException { - assertAllMethodsOverridden(ConnectorAccessControl.class, LegacyAccessControl.class, ImmutableSet.of( - LegacyAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class), - LegacyAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class))); + assertAllMethodsOverridden(ConnectorAccessControl.class, LegacyAccessControl.class); } } diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestSqlStandardAccessControl.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestSqlStandardAccessControl.java index b27d4fa16497..c1b7a64ebd7b 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestSqlStandardAccessControl.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/security/TestSqlStandardAccessControl.java @@ -13,11 +13,7 @@ */ package io.trino.plugin.hive.security; -import com.google.common.collect.ImmutableSet; import io.trino.spi.connector.ConnectorAccessControl; -import io.trino.spi.connector.ConnectorSecurityContext; -import io.trino.spi.connector.SchemaTableName; -import io.trino.spi.type.Type; import org.testng.annotations.Test; import static io.trino.spi.testing.InterfaceTestUtils.assertAllMethodsOverridden; @@ -28,8 +24,6 @@ public class TestSqlStandardAccessControl public void testEverythingImplemented() throws NoSuchMethodException { - assertAllMethodsOverridden(ConnectorAccessControl.class, SqlStandardAccessControl.class, ImmutableSet.of( - SqlStandardAccessControl.class.getMethod("getRowFilter", ConnectorSecurityContext.class, SchemaTableName.class), - SqlStandardAccessControl.class.getMethod("getColumnMask", ConnectorSecurityContext.class, SchemaTableName.class, String.class, Type.class))); + assertAllMethodsOverridden(ConnectorAccessControl.class, SqlStandardAccessControl.class); } }