Skip to content

Commit

Permalink
[trino] Update spi to v406
Browse files Browse the repository at this point in the history
Incorporate following changes

Remove deprecated checkCanCreateSchema
trinodb/trino#15618
trinodb/trino@0fac087

Disallow multiple masks on a given column
trinodb/trino#15680
trinodb/trino@bdd1cb5
  • Loading branch information
utk-spartan committed Mar 8, 2023
1 parent f02fd91 commit 726b548
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ public List<ViewExpression> getRowFilters(SystemSecurityContext context, Catalog
.orElse(Collections.emptyList());
}

private Optional<ViewExpression> getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) {
@Override
public Optional<ViewExpression> getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) {
RangerTrinoAccessRequest request = createAccessRequest(
createResource(tableName.getCatalogName(), tableName.getSchemaTableName().getSchemaName(),
tableName.getSchemaTableName().getTableName(), Optional.of(columnName)),
Expand Down Expand Up @@ -234,10 +235,11 @@ private Optional<ViewExpression> getColumnMask(SystemSecurityContext context, Ca
return Optional.ofNullable(viewExpression);
}

@Deprecated
@Override
public List<ViewExpression> getColumnMasks(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type)
{
// TODO{utk}: add implementation for multiple column masks
// TODO{utk}: remove, marked as deprecated, Trino no longer supports multiple masks as of v406
return getColumnMask(context, tableName, columnName, type)
.map(Collections::singletonList)
.orElse(Collections.emptyList());
Expand Down Expand Up @@ -352,14 +354,6 @@ public void checkCanShowCreateSchema(SystemSecurityContext context, CatalogSchem
* Create schema is evaluated on the level of the Catalog. This means that it is assumed you have permission
* to create a schema when you have create rights on the catalog level
*/

@Deprecated
@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema) {
// TODO{utk}: remove this method, marked as deprecated
checkCanCreateSchema(context, schema, new HashMap<String, Object>());
}

@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema, Map<String, Object> properties) {
if (!hasPermission(createResource(schema.getCatalogName()), context, TrinoAccessType.CREATE)) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<noggit.version>0.8</noggit.version>
<owasp-java-html-sanitizer.version>r239</owasp-java-html-sanitizer.version>
<paranamer.version>2.3</paranamer.version>
<trino.version>405</trino.version>
<trino.version>406</trino.version>
<poi.version>4.1.2</poi.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<protobuf-java.version>2.5.0</protobuf-java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,6 @@ public Set<String> filterCatalogs(SystemSecurityContext context, Set<String> cat
return filteredCatalogs;
}

@Deprecated
@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema) {
try {
activatePluginClassLoader();
systemAccessControlImpl.checkCanCreateSchema(context, schema);
} finally {
deactivatePluginClassLoader();
}
}

@Override
public void checkCanCreateSchema(SystemSecurityContext context, CatalogSchemaName schema, Map<String, Object> properties) {
try {
Expand Down Expand Up @@ -530,6 +519,20 @@ public List<ViewExpression> getRowFilters(SystemSecurityContext context, Catalog
}


@Override
public Optional<ViewExpression> getColumnMask(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) {
Optional<ViewExpression> viewExpression;
try {
activatePluginClassLoader();
viewExpression = systemAccessControlImpl.getColumnMask(context, tableName, columnName, type);
} finally {
deactivatePluginClassLoader();
}
return viewExpression;
}


@Deprecated
@Override
public List<ViewExpression> getColumnMasks(SystemSecurityContext context, CatalogSchemaTableName tableName, String columnName, Type type) {
List<ViewExpression> viewExpression;
Expand Down

0 comments on commit 726b548

Please sign in to comment.