-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[spark] Replace create existing tag semantic with replace_tag #4346
Conversation
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.
1、I think update_tag may be better?
2、You alse need modify flink action&& procedure and doc.
@@ -121,6 +121,19 @@ This section introduce all available spark procedures about paimon. | |||
CALL sys.rename_tag(table => 'default.T', tag_name => 'tag1', target_tag_name => 'tag2') | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>replace_tag</td> |
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.
I think update_tag may be better?
docs/content/spark/procedures.md
Outdated
Replace an existing tag with new tag info. Arguments: | ||
<li>table: the target table identifier. Cannot be empty.</li> | ||
<li>tag: name of the existed tag. Cannot be empty.</li> | ||
<li>snapshot(Long): id of the snapshot which the tag is based on.</li> |
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.
1、snapshotId
2、It is optional.
docs/content/spark/procedures.md
Outdated
<li>table: the target table identifier. Cannot be empty.</li> | ||
<li>tag: name of the existed tag. Cannot be empty.</li> | ||
<li>snapshot(Long): id of the snapshot which the tag is based on.</li> | ||
<li>time_retained: The maximum time retained for the existing tag.</li> |
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.
2、It is optional.
public void replaceTag(String tagName, @Nullable Duration timeRetained) { | ||
Snapshot latestSnapshot = snapshotManager().latestSnapshot(); | ||
SnapshotNotExistException.checkNotNull( | ||
latestSnapshot, "Cannot create tag because latest snapshot doesn't exist."); |
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 not update tag because latest snapshot doesn't exist.
findSnapshot(fromSnapshotId), | ||
tagName, | ||
timeRetained, | ||
store().createTagCallbacks()); |
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.
Here you should think this case:
If user update a tag, but he don't want call createTagCallbacks.
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.
good, replace the existing tag is no need to call callback again.
@@ -120,6 +120,12 @@ default String fullName() { | |||
@Experimental | |||
void renameTag(String tagName, String targetTagName); | |||
|
|||
@Experimental | |||
void replaceTag(String tagName, Duration timeRetained); |
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.
接口方法【replaceTag】必须使用javadoc注释
|
||
public void createOrReplaceTag( |
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.
createOrUpdateTag
new StructField[] { | ||
new StructField("result", DataTypes.BooleanType, true, Metadata.empty()) | ||
}); | ||
public class CreateTagProcedure extends CreateOrReplaceTagBaseProcedure { | ||
|
||
protected CreateTagProcedure(TableCatalog tableCatalog) { |
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.
why not private?
import java.time.Duration; | ||
|
||
/** A procedure to replace a tag. */ | ||
public class ReplaceTagTagProcedure extends CreateOrReplaceTagBaseProcedure { |
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.
UpdateTagProcedure
/** A procedure to replace a tag. */ | ||
public class ReplaceTagTagProcedure extends CreateOrReplaceTagBaseProcedure { | ||
|
||
protected ReplaceTagTagProcedure(TableCatalog tableCatalog) { |
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.
why not private?
addressed comments, thanks for review @wwj6591812 |
ok |
} | ||
|
||
@Override | ||
public void replaceTag(String tagName, long fromSnapshotId, @Nullable Duration timeRetained) { |
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.
Just create a replaceTag(String tagName, @Nullable Long fromSnapshotId, @Nullable Duration timeRetained)
?
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.
updated
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.
+1
Purpose
In default way, the create_tag procedure for an existing tag means to update it or fail, it's semantic is not very accurate, replace it with repalce_tag procedure.
before semantic
after semantic
Tests
API and Format
Documentation