Skip to content
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

[core] Support rename tag action and procedure #4277

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

xuzifu666
Copy link
Contributor

Purpose

Currently tag can not rename after create,this pr is aim to support it.

Linked issue: close #xxx

Tests

API and Format

Documentation

@xuzifu666 xuzifu666 changed the title [WIP][core] Support rename tag procedure [core] Support rename tag procedure Sep 29, 2024
<td>
CALL sys.rename_tag(table => 'default.T', tag_name => 'tag1', new_tag_name => 'tag2')
</td>
</tr>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_name will be better ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

try {
if (!tagExists(tagName)) {
throw new RuntimeException(String.format("tag: %s is not exists", tagName));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specified tag name [%s] does not exist ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import java.util.Optional;

/** Factory to create {@link RenameActionFactory}. */
public class RenameActionFactory implements ActionFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RenameTagActionFactory ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

public void run() throws Exception {
if (StringUtils.isEmpty(tagName) || StringUtils.isEmpty(newTagName)) {
throw new RuntimeException(String.format("tagName or newTagName can not be empty"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.format("The specified tag name [%s] or target tag name [%s] cannot be empty.", tagName, targetName)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

throws Catalog.TableNotExistException {
Table table = catalog.getTable(Identifier.fromString(tableId));
table.renameTag(tagName, newTagName);
return new String[] {"Success"};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return : Rename [%s] to [%s] successfully .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@xuzifu666
Copy link
Contributor Author

Thanks for @LinMingQiang review. Had addressed comments.

@LinMingQiang
Copy link
Contributor

+1

@xuzifu666 xuzifu666 closed this Sep 29, 2024
@xuzifu666 xuzifu666 reopened this Sep 29, 2024
<tr>
<td>rename_tag</td>
<td>
Rename tag to new tag name. Arguments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename a tag with a new tag name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<tr>
<td>rename_tag</td>
<td>
Rename tag to new tag name. Arguments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename a tag with a new tag name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import java.util.Optional;

/** Factory to create {@link RenameActionTagFactory}. */
public class RenameActionTagFactory implements ActionFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RenameTagActionFactory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/** Factory to create {@link RenameActionTagFactory}. */
public class RenameActionTagFactory implements ActionFactory {

public static final String IDENTIFIER = "rename_tag";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


@Override
public void printHelp() {
System.out.println("Action \"rename_tag\" rename a tag with a new tagname.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: In word 'tagname'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import org.apache.flink.table.procedure.ProcedureContext;

/**
* Create tag procedure. Usage:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create tag procedure?

argument = {
@ArgumentHint(name = "table", type = @DataTypeHint("STRING")),
@ArgumentHint(name = "tagName", type = @DataTypeHint("STRING")),
@ArgumentHint(name = "targetTagName", type = @DataTypeHint("STRING"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* </code></pre>
*/
public class RenameTagProcedure extends ProcedureBase {
public static final String IDENTIFIER = "rename_tag";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Rename tag to new tag name. Arguments:
<li>table: the target table identifier. Cannot be empty.</li>
<li>tag_name: name of the tag. Cannot be empty.</li>
<li>target_tag_name: the new tag name to rename.</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_tag_name: the new tag name to rename. Cannot be empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wwj6591812
Copy link
Contributor

Why you need this feature?
What the business scenario need this feature in your company?

@wwj6591812
Copy link
Contributor

Change title to :"Support rename tag action and procedure.";

@xuzifu666
Copy link
Contributor Author

xuzifu666 commented Sep 30, 2024

Why you need this feature?
What the business scenario need this feature in your company?

Yes, if user want to modify tag name which was not normative need the feature. Currently user cannot rename tag in a direct way, and if snapshot expire user cannot rename tag any more. @wwj6591812

@xuzifu666 xuzifu666 changed the title [core] Support rename tag procedure [core] Support rename tag action and procedure Oct 1, 2024
@xuzifu666
Copy link
Contributor Author

Thanks for @wwj6591812 review, had addressed comments.

@wwj6591812
Copy link
Contributor

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants