-
Notifications
You must be signed in to change notification settings - Fork 14k
[FLINK-38262][table] alter connection rename operation #28793
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?
Changes from 1 commit
1fdc876
453ab76
acaf5c8
390042e
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * 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.operations.ddl; | ||
|
|
||
| import org.apache.flink.annotation.Internal; | ||
| import org.apache.flink.table.api.internal.TableResultImpl; | ||
| import org.apache.flink.table.api.internal.TableResultInternal; | ||
| import org.apache.flink.table.catalog.ObjectIdentifier; | ||
|
|
||
| /** Operation for ALTER CONNECTION .. RENAME TO .. statements. */ | ||
| @Internal | ||
| public class AlterConnectionRenameOperation implements AlterOperation { | ||
|
|
||
| private final ObjectIdentifier connectionIdentifier; | ||
| private final String newConnectionName; | ||
| private final boolean ignoreIfNotExists; | ||
|
|
||
| public AlterConnectionRenameOperation( | ||
| ObjectIdentifier connectionIdentifier, | ||
| String newConnectionName, | ||
| boolean ignoreIfNotExists) { | ||
| this.connectionIdentifier = connectionIdentifier; | ||
| this.newConnectionName = newConnectionName; | ||
| this.ignoreIfNotExists = ignoreIfNotExists; | ||
| } | ||
|
|
||
| public ObjectIdentifier getConnectionIdentifier() { | ||
| return connectionIdentifier; | ||
| } | ||
|
|
||
| public String getNewConnectionName() { | ||
| return newConnectionName; | ||
| } | ||
|
|
||
| public boolean ignoreIfNotExists() { | ||
| return ignoreIfNotExists; | ||
| } | ||
|
|
||
| @Override | ||
| public String asSummaryString() { | ||
| return String.format( | ||
| "ALTER CONNECTION %s%s RENAME TO %s", | ||
| ignoreIfNotExists ? "IF EXISTS " : "", | ||
| connectionIdentifier.asSummaryString(), | ||
| newConnectionName); | ||
| } | ||
|
|
||
| @Override | ||
| public TableResultInternal execute(Context ctx) { | ||
| ctx.getCatalogManager() | ||
| .renameConnection(connectionIdentifier, newConnectionName, ignoreIfNotExists); | ||
| return TableResultImpl.TABLE_RESULT_OK; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1041,6 +1041,26 @@ default void alterConnection( | |
| this.getClass())); | ||
| } | ||
|
|
||
| /** | ||
| * Rename an existing connection. | ||
| * | ||
| * @param connectionPath Path of the connection to be renamed | ||
| * @param newConnectionName the new name of the connection | ||
| * @param ignoreIfNotExists Flag to specify behavior when the connection does not exist: if set | ||
| * to false, throw an exception, if set to true, do nothing. | ||
| * @throws ConnectionNotExistException if the connection does not exist | ||
| * @throws ConnectionAlreadyExistException if a connection with the new name already exists | ||
| * @throws CatalogException in case of any runtime exception | ||
| */ | ||
| default void renameConnection( | ||
| ObjectPath connectionPath, String newConnectionName, boolean ignoreIfNotExists) | ||
| throws ConnectionNotExistException, ConnectionAlreadyExistException, CatalogException { | ||
| throw new UnsupportedOperationException( | ||
| String.format( | ||
| "renameConnection(ObjectPath, String, boolean) is not implemented for %s.", | ||
| this.getClass())); | ||
| } | ||
|
|
||
|
Comment on lines
+1044
to
+1063
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. Is the community aligned with adding this to the public API? I haven't seen a Mailing Thread or FLIP on this. Maybe I have missed it.
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. Moreover, in the PR description you mentioned:
Which is not the case here
Contributor
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.
Contributor
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. |
||
| /** | ||
| * Drop a connection. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * 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.planner.operations.converters; | ||
|
|
||
| import org.apache.flink.sql.parser.ddl.connection.SqlAlterConnectionRename; | ||
| import org.apache.flink.table.catalog.ObjectIdentifier; | ||
| import org.apache.flink.table.catalog.UnresolvedIdentifier; | ||
| import org.apache.flink.table.operations.Operation; | ||
| import org.apache.flink.table.operations.ddl.AlterConnectionRenameOperation; | ||
|
|
||
| /** A converter for {@link SqlAlterConnectionRename}. */ | ||
| public class SqlAlterConnectionRenameConverter | ||
| implements SqlNodeConverter<SqlAlterConnectionRename> { | ||
|
|
||
| @Override | ||
| public Operation convertSqlNode( | ||
| SqlAlterConnectionRename sqlAlterConnectionRename, ConvertContext context) { | ||
| ObjectIdentifier connectionIdentifier = | ||
| context.getCatalogManager() | ||
| .qualifyIdentifier( | ||
| UnresolvedIdentifier.of(sqlAlterConnectionRename.getFullName())); | ||
|
|
||
| return new AlterConnectionRenameOperation( | ||
| connectionIdentifier, | ||
| sqlAlterConnectionRename.getNewConnectionName().getSimple(), | ||
| sqlAlterConnectionRename.ifConnectionExists()); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.