Skip to content

Conversation

@hililiwei
Copy link
Contributor

@hililiwei hililiwei commented Jan 21, 2023

Co-authored-by: Amogh Jahagirdar [email protected]
Co-authored-by: chidayong [email protected]

What is the purpose of the change

Implement the syntax in the following documents:
https://docs.google.com/document/d/1tbATFPrKF3vNlzkgZQdaW8CAJmbjvryfrlg6C2Ci_aA/edit

Create TAG

ALTER TABLE table CREAT TAG tagName
[AS OF {VERSION snapshotId}]
[RETAIN interval {DAYS | HOURS | MINUTES}]

e.g.

ALTER TABLE table CREATE TAG historical_annual_snapshot
AS OF VERSION 100
RETAIN 12 DAYS

cc @jackye1995 @amogh-jahagirdar

@github-actions github-actions bot added the spark label Jan 21, 2023
@hililiwei
Copy link
Contributor Author

In the original proposal, it was "[RETAIN For interval {DAYS | HOURS | MINUTES}]", but in keeping with CREATE BRANCH, I removed the" For" key. What do you think about that? @jackye1995 @amogh-jahagirdar

@jackye1995
Copy link
Contributor

Good point, +1 for only RETAIN because https://docs.databricks.com/sql/language-manual/delta-vacuum.html

@amogh-jahagirdar
Copy link
Contributor

In the original proposal, it was "[RETAIN For interval {DAYS | HOURS | MINUTES}]", but in keeping with CREATE BRANCH, I removed the" For" key. What do you think about that? @jackye1995 @amogh-jahagirdar

Ah yes, we should remove the FOR clause. That's a mistake in the proposal on my part. Updated the proposal.

Copy link
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, I will ignore the duplicated code and do another pass after rebase. Added 2 comments for discussion.

@hililiwei hililiwei force-pushed the spark_sql_extend_for_create_tag branch 3 times, most recently from effe7e9 to 6b94b9c Compare January 23, 2023 15:35
@amogh-jahagirdar
Copy link
Contributor

amogh-jahagirdar commented Feb 2, 2023

@hililiwei similar to #6638 could this PR encapsulate create/replace? We came to the conclusion on the replaceBranch PR it made more sense to just combine them. at the end of the day the logical plan needs to pass through whether it's a replace or not and it is a bit more concise in the grammar definition to combine them while still maintaining readability

@jackye1995
Copy link
Contributor

could this PR encapsulate create/replace?

+1

Let me know when this is updated, I will take another look!

@hililiwei hililiwei force-pushed the spark_sql_extend_for_create_tag branch 2 times, most recently from 9d16516 to 8f73631 Compare February 3, 2023 04:37
;

tagOptions
: (AS OF VERSION snapshotId)? (refRetain)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I just noticed this ; in the end, also in branchOptions. @amogh-jahagirdar is this required? It doesn't feel like required to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is required. We can insert a new line, consistent with the rest.

normalized.contains("replace branch")
normalized.contains("create branch") ||
normalized.contains("replace branch") ||
normalized.contains("create tag")))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a fix for this at #6728 , might want to rebase after that is merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it.


/**
* Create an CREATE OR REPLACE BRANCH logical command.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

nice catches! But can we avoid unrelated changes in the PR? @amogh-jahagirdar I think you should fix these separately

Copy link
Contributor

Choose a reason for hiding this comment

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

btw I am surprised that checkstyle did not catch that extra space, maybe it needs some more configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For scala, our checkstyle needs to be improved. And auto-formatting doesn't work yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch @hililiwei , I'll update #6728 to fix the styling issues. We should track an issue for scala checkstyle/autoformatting , admittedly I rely on that quite heavily to catch these kinds of issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Created #6736 and updated #6728 to include styling fixes

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I merged #6728

@jackye1995
Copy link
Contributor

Apart from the style changes for branch that can now be removed, I have no further comments. Let me know when this is rebased!

@aokolnychyi
Copy link
Contributor

hililiwei and others added 2 commits February 6, 2023 10:04
Co-authored-by: Amogh Jahagirdar <[email protected]>
Co-authored-by: chidayong <[email protected]>
@hililiwei hililiwei force-pushed the spark_sql_extend_for_create_tag branch 2 times, most recently from 8a8c670 to 9dbdbed Compare February 6, 2023 07:02
@hililiwei hililiwei force-pushed the spark_sql_extend_for_create_tag branch 2 times, most recently from 03eacc8 to 3c60df2 Compare February 6, 2023 07:06
@hililiwei hililiwei force-pushed the spark_sql_extend_for_create_tag branch from 3c60df2 to f51effa Compare February 6, 2023 07:07
@hililiwei hililiwei requested review from jackye1995 and removed request for flyrain and yyanyy February 6, 2023 08:46
@hililiwei
Copy link
Contributor Author

hililiwei requested review from jackye1995 and removed request for flyrain and yyanyy

Misclick. 😂

Apart from the style changes for branch that can now be removed, I have no further comments. Let me know when this is rebased!

PTAL, thx.

Copy link
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me! @amogh-jahagirdar @aokolnychyi any further comments?

import org.junit.Test;
import org.junit.runners.Parameterized;

public class TestReplaceTag extends SparkExtensionsTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move all the tag tests to TestTagDDL based on the discussion here #6752 (comment)? Not blocking for this PR we can get in a follow on, but it's basically just to ensure the test runs aren't super slow with all the spark setup which will happen for every test class if we have a test class per statement.

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

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

Thanks LiWei, one non-blocking comment on our test setup for all the branching/tagging DDLs. We can address on a follow on PR.

@hililiwei hililiwei force-pushed the spark_sql_extend_for_create_tag branch from 8da50f4 to 68c0353 Compare February 10, 2023 03:22
Copy link
Contributor

@yyanyy yyanyy left a comment

Choose a reason for hiding this comment

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

lgtm!

@jackye1995
Copy link
Contributor

All the comments are addressed and we have enough votes, so I will go ahead to merge it. I requested @aokolnychyi for further review and approval, but given it has been quite a few days, and there is a subsequent DROP TAG PR anyway, we can move forward and address any missing comments there.

Thanks for the contribution @hililiwei , and thanks everyone for the review!

@jackye1995 jackye1995 merged commit 4c06b4c into apache:master Feb 10, 2023
@hililiwei hililiwei deleted the spark_sql_extend_for_create_tag branch February 11, 2023 01:59
krvikash pushed a commit to krvikash/iceberg that referenced this pull request Mar 16, 2023
Co-authored-by: Amogh Jahagirdar <[email protected]>
Co-authored-by: chidayong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants