-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-38848] [table] Supports to pass the required privilege when catalog manager gets the table #27389
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
base: master
Are you sure you want to change the base?
[FLINK-38848] [table] Supports to pass the required privilege when catalog manager gets the table #27389
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 |
|---|---|---|
|
|
@@ -687,7 +687,19 @@ public Optional<ContextResolvedTable> getTable(ObjectIdentifier objectIdentifier | |
| resolveCatalogBaseTable(temporaryTable); | ||
| return Optional.of(ContextResolvedTable.temporary(objectIdentifier, resolvedTable)); | ||
| } else { | ||
| return getPermanentTable(objectIdentifier, null); | ||
|
Contributor
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 think this is an exciting addition, I think it is big enough to warrant a Flip.
Author
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. This pull request includes all the required code. It doesn't have many changes. FLIP may need many code changes in my opinion.
Contributor
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. @jerqi Thankyou I suggest starting a discussion on the dev list to see if it warrants a Flip. |
||
| return getPermanentTable(objectIdentifier, null, null); | ||
| } | ||
| } | ||
|
|
||
| public Optional<ContextResolvedTable> getTable( | ||
| ObjectIdentifier objectIdentifier, Set<TableWritePrivilege> privileges) { | ||
| CatalogBaseTable temporaryTable = temporaryTables.get(objectIdentifier); | ||
| if (temporaryTable != null) { | ||
| final ResolvedCatalogBaseTable<?> resolvedTable = | ||
| resolveCatalogBaseTable(temporaryTable); | ||
| return Optional.of(ContextResolvedTable.temporary(objectIdentifier, resolvedTable)); | ||
| } else { | ||
| return getPermanentTable(objectIdentifier, null, privileges); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -708,7 +720,7 @@ public Optional<ContextResolvedTable> getTable( | |
| resolveCatalogBaseTable(temporaryTable); | ||
| return Optional.of(ContextResolvedTable.temporary(objectIdentifier, resolvedTable)); | ||
| } else { | ||
| return getPermanentTable(objectIdentifier, timestamp); | ||
| return getPermanentTable(objectIdentifier, timestamp, null); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -753,6 +765,17 @@ public ContextResolvedTable getTableOrError(ObjectIdentifier objectIdentifier) { | |
| objectIdentifier, listCatalogs()))); | ||
| } | ||
|
|
||
| public ContextResolvedTable getTableOrError( | ||
| ObjectIdentifier objectIdentifier, Set<TableWritePrivilege> privileges) { | ||
| return getTable(objectIdentifier, privileges) | ||
| .orElseThrow( | ||
| () -> | ||
| new ValidationException( | ||
| String.format( | ||
| "Cannot find table '%s' in any of the catalogs %s, nor as a temporary table.", | ||
| objectIdentifier, listCatalogs()))); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves a partition with a fully qualified table path and partition spec. If the path is | ||
| * not yet fully qualified use{@link #qualifyIdentifier(UnresolvedIdentifier)} first. | ||
|
|
@@ -777,7 +800,9 @@ public Optional<CatalogPartition> getPartition( | |
| } | ||
|
|
||
| private Optional<ContextResolvedTable> getPermanentTable( | ||
| ObjectIdentifier objectIdentifier, @Nullable Long timestamp) { | ||
| ObjectIdentifier objectIdentifier, | ||
| @Nullable Long timestamp, | ||
| @Nullable Set<TableWritePrivilege> privileges) { | ||
| Optional<Catalog> catalogOptional = getCatalog(objectIdentifier.getCatalogName()); | ||
| ObjectPath objectPath = objectIdentifier.toObjectPath(); | ||
| if (catalogOptional.isPresent()) { | ||
|
|
@@ -792,6 +817,8 @@ private Optional<ContextResolvedTable> getPermanentTable( | |
| "%s is a view, but time travel is not supported for view.", | ||
| objectIdentifier.asSummaryString())); | ||
| } | ||
| } else if (privileges != null) { | ||
| table = currentCatalog.getTable(objectPath, privileges); | ||
| } else { | ||
| table = currentCatalog.getTable(objectPath); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.flink.table.catalog; | ||
|
|
||
| import org.apache.flink.annotation.PublicEvolving; | ||
|
|
||
| /** The table writing privileges that will be provided when loading a table. */ | ||
| @PublicEvolving | ||
| public enum TableWritePrivilege { | ||
| /** The privilege of adding rows to the table. */ | ||
| INSERT, | ||
|
|
||
| /** The privilege for changing existing rows in the table. */ | ||
| UPDATE, | ||
|
|
||
| /** The privilege for deleting rows from the table. */ | ||
| DELETE | ||
| } |
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.
this needs to have junit tests added to drive the new code paths