MERGE BRANCH
Merge a branch in an Arctic catalog.
To run MERGE BRANCH, users need the USAGE and COMMIT privileges on the Arctic catalog. In the following cases, users need additional privileges:
- If a table on the source branch was updated, whether inserted or altered, users also need the WRITE privilege on the catalog, any parent folder for the table, or the table itself.
- If a table on the source branch was deleted, users also need the OWNERSHIP privilege on the catalog, any parent folder for the table, or the table itself.
- If a folder was created on the source branch and does not exist in the target branch, users also need the CREATE FOLDER privilege on the catalog or any parent folder for the folder.
- If a table was created on the source branch and does not exist in the target branch, users also need the CREATE TABLE privilege on the catalog or any parent folder for the table.
- If a view was created on the source branch and does not exist in the target branch, users also need the CREATE VIEW privilege on the catalog or any parent folder for the view.
MERGE BRANCH [ DRY RUN ] <source_branch_name>
[ INTO <target_branch_name> ]
[ IN <catalog_name> ]
[ ON CONFLICT { OVERWRITE | DISCARD | CANCEL }
[ EXCEPT { OVERWRITE | DISCARD | CANCEL } <content_name> [, <content_name>, ...]]
[ EXCEPT { OVERWRITE | DISCARD | CANCEL } <content_name> [, <content_name>, ...]]
Parameters
DRY RUN Optional
Returns an output that determines if the MERGE BRANCH command would be successful without committing the command.
Sample output upon success:
Message | ContentName | Status |
---|---|---|
Branch <source_branch_name> can be merged into <target_branch_name> | null | SUCCESS |
Sample output upon failure:
Message | ContentName | Status |
---|---|---|
Branch <source_branch_name> cannot be merged into <target_branch_name> | null | FAILURE |
<source_branch_name> String
The name of the branch that you want to merge into your target branch. If a target branch is not specified, the source branch is merged into the current branch you are in.
INTO <target_branch_name> String Optional
The name of the branch that is the target for the merge. If you do not use this optional clause and the reference is a branch, the query will still run successfully. However, if the reference is not a branch, the query will fail because you can merge only branches.
IN <catalog_name> String Optional
The name of the Arctic catalog. If not specified, the current Arctic catalog in the query context is used.
ON CONFLICT { OVERWRITE | DISCARD | CANCEL } Optional
Decides how to resolve a conflict when merging the branch. When this parameter is omitted, the default is CANCEL.
If the branch has a merge conflict, then the command follows one of these specified actions:
- OVERWRITE: The version of the table or view from the
<source_branch_name>
becomes the current version on<target_branch_name>
after the merge. - DISCARD: The version of the table or view on
<target_branch_name>
remains the same after the merge and the version of the table or view from<source_branch_name>
is discarded. - CANCEL: The merge fails and no changes are committed.
EXCEPT { OVERWRITE | DISCARD | CANCEL } <content_name> [, <content_name>, ...] String Optional
Provides an exception for specific content when resolving a merge conflict. You can specify more than one content name in each EXCEPT clause by using commas to separate the content names. You can use a maximum of two EXCEPT clauses, but the clauses cannot contain the same content. If an EXCEPT clause is the same as the ON CONFLICT clause or the other EXCEPT clause in the query, then the operation is cancelled.
If the branch has a merge conflict, then the command follows one of these specified actions:
- OVERWRITE: The version of the content from the
<source_branch_name>
becomes the current version on<target_branch_name>
after the merge. - DISCARD: The version of the content on
<target_branch_name>
remains the same after the merge and the version of the content from<source_branch_name>
is discarded. - CANCEL: The merge fails and no changes are committed.
<content_name>
is the name of the content for which the exception is being provided, such as the name of the view or table. Content names must be fully qualified.
Output
Sample output upon success:
Message | ContentName | Status |
---|---|---|
Branch <source_branch_name> has been merged into <target_branch_name> at <reference_name> | null | SUCCESS |
Sample output upon failure:
Message | Content Name | Status |
---|---|---|
Failed to merge branch <source_branch_name> into <target_branch_name> | null | FAILURE |
Examples
Merge a branch into the current reference branchMERGE BRANCH myBranch
MERGE BRANCH myBranch
INTO main
IN myCatalog;
MERGE BRANCH dev
INTO main
ON CONFLICT OVERWRITE;
MERGE BRANCH dev
INTO main
ON CONFLICT DISCARD;
MERGE BRANCH DRY RUN dev
INTO main
ON CONFLICT CANCEL;
tableA
MERGE BRANCH dev
INTO main
ON CONFLICT OVERWRITE
EXCEPT DISCARD catalogA.folderA.tableA;
tableA
and tableB
MERGE BRANCH dev
INTO main
ON CONFLICT OVERWRITE
EXCEPT DISCARD catalogA.folderA.tableA
EXCEPT CANCEL catalogA.folderA.tableB;