|
34 | 34 | import com.facebook.presto.spi.function.FunctionKind; |
35 | 35 | import com.facebook.presto.spi.function.table.Argument; |
36 | 36 | import com.facebook.presto.spi.function.table.ConnectorTableFunctionHandle; |
| 37 | +import com.facebook.presto.spi.procedure.DistributedProcedure; |
37 | 38 | import com.facebook.presto.spi.security.AccessControl; |
38 | 39 | import com.facebook.presto.spi.security.AccessControlContext; |
39 | 40 | import com.facebook.presto.spi.security.AllowAllAccessControl; |
@@ -176,6 +177,13 @@ public class Analysis |
176 | 177 | private final Multiset<ColumnMaskScopeEntry> columnMaskScopes = HashMultiset.create(); |
177 | 178 | private final Map<NodeRef<Table>, Map<String, Expression>> columnMasks = new LinkedHashMap<>(); |
178 | 179 |
|
| 180 | + // for call distributed procedure |
| 181 | + private Optional<DistributedProcedure.DistributedProcedureType> distributedProcedureType = Optional.empty(); |
| 182 | + private Optional<QualifiedObjectName> procedureName = Optional.empty(); |
| 183 | + private Optional<Object[]> procedureArguments = Optional.empty(); |
| 184 | + private Optional<TableHandle> callTarget = Optional.empty(); |
| 185 | + private Optional<QuerySpecification> targetQuery = Optional.empty(); |
| 186 | + |
179 | 187 | // for create table |
180 | 188 | private Optional<QualifiedObjectName> createTableDestination = Optional.empty(); |
181 | 189 | private Map<String, Expression> createTableProperties = ImmutableMap.of(); |
@@ -670,6 +678,46 @@ public Optional<QualifiedObjectName> getCreateTableDestination() |
670 | 678 | return createTableDestination; |
671 | 679 | } |
672 | 680 |
|
| 681 | + public Optional<QualifiedObjectName> getProcedureName() |
| 682 | + { |
| 683 | + return procedureName; |
| 684 | + } |
| 685 | + |
| 686 | + public void setProcedureName(Optional<QualifiedObjectName> procedureName) |
| 687 | + { |
| 688 | + this.procedureName = procedureName; |
| 689 | + } |
| 690 | + |
| 691 | + public Optional<DistributedProcedure.DistributedProcedureType> getDistributedProcedureType() |
| 692 | + { |
| 693 | + return distributedProcedureType; |
| 694 | + } |
| 695 | + |
| 696 | + public void setDistributedProcedureType(Optional<DistributedProcedure.DistributedProcedureType> distributedProcedureType) |
| 697 | + { |
| 698 | + this.distributedProcedureType = distributedProcedureType; |
| 699 | + } |
| 700 | + |
| 701 | + public Optional<Object[]> getProcedureArguments() |
| 702 | + { |
| 703 | + return procedureArguments; |
| 704 | + } |
| 705 | + |
| 706 | + public void setProcedureArguments(Optional<Object[]> procedureArguments) |
| 707 | + { |
| 708 | + this.procedureArguments = procedureArguments; |
| 709 | + } |
| 710 | + |
| 711 | + public Optional<TableHandle> getCallTarget() |
| 712 | + { |
| 713 | + return callTarget; |
| 714 | + } |
| 715 | + |
| 716 | + public void setCallTarget(TableHandle callTarget) |
| 717 | + { |
| 718 | + this.callTarget = Optional.of(callTarget); |
| 719 | + } |
| 720 | + |
673 | 721 | public Optional<TableHandle> getAnalyzeTarget() |
674 | 722 | { |
675 | 723 | return analyzeTarget; |
@@ -931,12 +979,12 @@ public Map<AccessControlInfo, Map<QualifiedObjectName, Set<String>>> getUtilized |
931 | 979 | return ImmutableMap.copyOf(utilizedTableColumnReferences); |
932 | 980 | } |
933 | 981 |
|
934 | | - public void populateTableColumnAndSubfieldReferencesForAccessControl(boolean checkAccessControlOnUtilizedColumnsOnly, boolean checkAccessControlWithSubfields) |
| 982 | + public void populateTableColumnAndSubfieldReferencesForAccessControl(boolean checkAccessControlOnUtilizedColumnsOnly, boolean checkAccessControlWithSubfields, boolean isLegacyMaterializedViews) |
935 | 983 | { |
936 | | - accessControlReferences.addTableColumnAndSubfieldReferencesForAccessControl(getTableColumnAndSubfieldReferencesForAccessControl(checkAccessControlOnUtilizedColumnsOnly, checkAccessControlWithSubfields)); |
| 984 | + accessControlReferences.addTableColumnAndSubfieldReferencesForAccessControl(getTableColumnAndSubfieldReferencesForAccessControl(checkAccessControlOnUtilizedColumnsOnly, checkAccessControlWithSubfields, isLegacyMaterializedViews)); |
937 | 985 | } |
938 | 986 |
|
939 | | - private Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> getTableColumnAndSubfieldReferencesForAccessControl(boolean checkAccessControlOnUtilizedColumnsOnly, boolean checkAccessControlWithSubfields) |
| 987 | + private Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> getTableColumnAndSubfieldReferencesForAccessControl(boolean checkAccessControlOnUtilizedColumnsOnly, boolean checkAccessControlWithSubfields, boolean isLegacyMaterializedViews) |
940 | 988 | { |
941 | 989 | Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> references; |
942 | 990 | if (!checkAccessControlWithSubfields) { |
@@ -968,19 +1016,26 @@ else if (!checkAccessControlOnUtilizedColumnsOnly) { |
968 | 1016 | }) |
969 | 1017 | .collect(toImmutableSet()))))); |
970 | 1018 | } |
971 | | - return buildMaterializedViewAccessControl(references); |
| 1019 | + return buildMaterializedViewAccessControl(references, isLegacyMaterializedViews); |
972 | 1020 | } |
973 | 1021 |
|
974 | 1022 | /** |
975 | | - * For a query on materialized view, only check the actual required access controls for its base tables. For the materialized view, |
976 | | - * will not check access control by replacing with AllowAllAccessControl. |
| 1023 | + * For a query on materialized view: |
| 1024 | + * - When legacy_materialized_views=true: Only check access controls for base tables, bypass access control |
| 1025 | + * for the materialized view itself by replacing with AllowAllAccessControl. |
| 1026 | + * - When legacy_materialized_views=false: Check access control for both the materialized view itself |
| 1027 | + * and all base tables referenced in the view query. |
977 | 1028 | **/ |
978 | | - private Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> buildMaterializedViewAccessControl(Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> tableColumnReferences) |
| 1029 | + private Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> buildMaterializedViewAccessControl(Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> tableColumnReferences, boolean isLegacyMaterializedViews) |
979 | 1030 | { |
980 | 1031 | if (!(getStatement() instanceof Query) || materializedViews.isEmpty()) { |
981 | 1032 | return tableColumnReferences; |
982 | 1033 | } |
983 | 1034 |
|
| 1035 | + if (!isLegacyMaterializedViews) { |
| 1036 | + return tableColumnReferences; |
| 1037 | + } |
| 1038 | + |
984 | 1039 | Map<AccessControlInfo, Map<QualifiedObjectName, Set<Subfield>>> newTableColumnReferences = new LinkedHashMap<>(); |
985 | 1040 |
|
986 | 1041 | tableColumnReferences.forEach((accessControlInfo, references) -> { |
@@ -1037,6 +1092,16 @@ public Optional<QuerySpecification> getCurrentQuerySpecification() |
1037 | 1092 | return currentQuerySpecification; |
1038 | 1093 | } |
1039 | 1094 |
|
| 1095 | + public void setTargetQuery(QuerySpecification targetQuery) |
| 1096 | + { |
| 1097 | + this.targetQuery = Optional.of(targetQuery); |
| 1098 | + } |
| 1099 | + |
| 1100 | + public Optional<QuerySpecification> getTargetQuery() |
| 1101 | + { |
| 1102 | + return this.targetQuery; |
| 1103 | + } |
| 1104 | + |
1040 | 1105 | public Map<FunctionKind, Set<String>> getInvokedFunctions() |
1041 | 1106 | { |
1042 | 1107 | Map<FunctionKind, Set<String>> functionMap = new HashMap<>(); |
|
0 commit comments