feat(datafusion): support the create_branch procedure - #939
jackylee-ch wants to merge 3 commits into
Conversation
|
Requirement fit: SUPPORTED. Normal branch creation, duplicate handling, and a branch created from a tag worked in local DataFusion SQL tests. However, P1: reject path separators in branch names. The shared |
Review follow-up (apache#939): `BranchManager::validate_branch_name` accepted a name containing a path separator such as `b1/hidden`, so `sys.create_branch` created a branch directory at a nested path (`branch-b1/hidden`) that `$branches` never lists back — a silently orphaned branch. Reject '/' and '\\' in branch names, alongside the existing main/blank/numeric checks.
Java exposes `sys.create_branch(table, branch[, tag][, ignore_if_exists])` to fork a branch off the current schema or a tag without touching main. The core BranchManager primitives already existed; only the DataFusion procedure was missing (apache#290/apache#482 wired the branch reader and manager, not the CALL). Register create_branch: declare its table/branch/tag/ignore_if_exists parameters (so a misspelled argument is rejected, like Java's binding) and dispatch to BranchManager -- creating from a tag when one is given, and treating an existing branch as a no-op only when ignore_if_exists is set.
Review follow-up (apache#939): `BranchManager::validate_branch_name` accepted a name containing a path separator such as `b1/hidden`, so `sys.create_branch` created a branch directory at a nested path (`branch-b1/hidden`) that `$branches` never lists back — a silently orphaned branch. Reject '/' and '\\' in branch names, alongside the existing main/blank/numeric checks.
Add the SQL regression requested in review: after creating `b1`, `CALL sys.create_branch(..., branch => 'b1/hidden')` must fail with the path-separator error, leave no nested directory under `branch-b1/`, and keep `$branches` at the single `b1` row.
4b061cf to
fae33f6
Compare
|
Addressed. |
Java exposes
sys.create_branch(table, branch[, tag][, ignore_if_exists])to fork a branch off the current schema or a tag without touchingmain. The coreBranchManager::create_branch/create_branch_from_tagprimitives already existed (#290/#482 wired the branch reader and manager); only the DataFusionCALLprocedure was missing.This registers
create_branch: it declares thetable/branch/tag/ignore_if_existsparameters so a misspelled argument is rejected (matching Java's binding), and dispatches toBranchManager— creating from a tag when one is given, and treating an existing branch as a no-op only whenignore_if_existsis set.Tested end-to-end: CALL, then assert the branch appears in
$branches; recreating errors; recreating withignore_if_existsis a no-op.