-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
HIVE-28763: Iceberg: Support functions while expiring snapshots. #5643
Conversation
-> ^(TOK_ALTERTABLE_EXECUTE KW_EXPIRE_SNAPSHOTS $expireParam?) | ||
| KW_EXECUTE KW_SET_CURRENT_SNAPSHOT LPAREN (snapshotParam=expression) RPAREN | ||
-> ^(TOK_ALTERTABLE_EXECUTE KW_SET_CURRENT_SNAPSHOT $snapshotParam) | ||
| KW_EXECUTE KW_FAST_FORWARD sourceBranch=StringLiteral (targetBranch=StringLiteral)? | ||
-> ^(TOK_ALTERTABLE_EXECUTE KW_FAST_FORWARD $sourceBranch $targetBranch?) | ||
| KW_EXECUTE KW_CHERRY_PICK snapshotId=Number | ||
-> ^(TOK_ALTERTABLE_EXECUTE KW_CHERRY_PICK $snapshotId) | ||
| KW_EXECUTE KW_EXPIRE_SNAPSHOTS KW_BETWEEN (fromTimestamp=StringLiteral) KW_AND (toTimestamp=StringLiteral) | ||
| KW_EXECUTE KW_EXPIRE_SNAPSHOTS KW_BETWEEN |
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.
| KW_EXECUTE KW_EXPIRE_SNAPSHOTS KW_BETWEEN | |
| KW_EXECUTE KW_EXPIRE_SNAPSHOTS KW_BETWEEN |
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.
done
QueryState queryState = new QueryState.Builder().withGenerateNewQueryId(false).withHiveConf(conf).build(); | ||
SemanticAnalyzer sem = (SemanticAnalyzer) SemanticAnalyzerFactory.get(queryState, node); | ||
ExprNodeDesc desc = sem.genExprNodeDesc(node, new RowResolver(), false, true); | ||
ExprNodeConstantDesc constantDesc = (ExprNodeConstantDesc) desc; |
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'd check if it is a constant or not. This throws ClassCastException.
shell.executeStatement("ALTER TABLE " + identifier.name() + " EXECUTE EXPIRE_SNAPSHOTS(RAND())");
Additionally, we may check whether the type of constantDesc
is acceptable here.
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 added a check that desc is of type ExprNodeConstantDesc, whether constantDesc
is acceptable or not I think the original logic should take care, It should throw some DateTimeParsing exception, same as in case some one provides non timestamp string
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.
LGTM
|
What changes were proposed in this pull request?
Allow specifying functions while expiring snapshots
Why are the changes needed?
Better Usability
Does this PR introduce any user-facing change?
Yes, Expire Snapshots allows valid expressions
Is the change a dependency upgrade?
No
How was this patch tested?
UT