-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter table columns in bulk #18956
Filter table columns in bulk #18956
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.google.common.collect.Maps; | ||
import com.google.inject.Inject; | ||
import io.airlift.log.Logger; | ||
import io.airlift.stats.CounterStat; | ||
|
@@ -635,6 +636,34 @@ public Set<String> filterColumns(SecurityContext securityContext, CatalogSchemaT | |
return columns; | ||
} | ||
|
||
@Override | ||
public Map<SchemaTableName, Set<String>> filterColumns(SecurityContext securityContext, String catalogName, Map<SchemaTableName, Set<String>> tableColumns) | ||
{ | ||
requireNonNull(securityContext, "securityContext is null"); | ||
requireNonNull(catalogName, "catalogName is null"); | ||
requireNonNull(tableColumns, "tableColumns is null"); | ||
|
||
Set<SchemaTableName> filteredTables = filterTables(securityContext, catalogName, tableColumns.keySet()); | ||
if (!filteredTables.equals(tableColumns.keySet())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would expect equals to invoke contains only if sets are equal (size chcked first?), and there is no second call then for given element |
||
tableColumns = Maps.filterKeys(tableColumns, filteredTables::contains); | ||
} | ||
|
||
if (tableColumns.isEmpty()) { | ||
// Do not call plugin-provided implementation unnecessarily. | ||
return ImmutableMap.of(); | ||
} | ||
|
||
for (SystemAccessControl systemAccessControl : getSystemAccessControls()) { | ||
tableColumns = systemAccessControl.filterColumns(securityContext.toSystemSecurityContext(), catalogName, tableColumns); | ||
} | ||
|
||
ConnectorAccessControl connectorAccessControl = getConnectorAccessControl(securityContext.getTransactionId(), catalogName); | ||
if (connectorAccessControl != null) { | ||
tableColumns = connectorAccessControl.filterColumns(toConnectorSecurityContext(catalogName, securityContext), tableColumns); | ||
} | ||
return tableColumns; | ||
} | ||
|
||
@Override | ||
public void checkCanAddColumns(SecurityContext securityContext, QualifiedObjectName tableName) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can all redirected tables be collected and batched in a single
accessControl.filterColumns
call?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they would need to be grouped by catalog, but yes, that's possible
note that there are also other deficiencies around redirected tables handling. this requires test coverage and is not the part i am focusing on