Skip to content

Commit

Permalink
Add validations at RPC level too for reference table params
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Sep 18, 2024
1 parent 270a289 commit 64802a5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,17 @@ func (s *Server) Materialize(ctx context.Context, ms *vtctldatapb.MaterializeSet
cells[i] = strings.TrimSpace(cells[i])
}

switch {
case ms.IsReference && len(ms.Tables) == 0:
return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "no tables specified for reference table materialization")
case len(ms.Tables) > 0 && !ms.IsReference:
return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "tables specified for non-reference table materialization")
case !ms.IsReference && len(ms.TableSettings) == 0:
return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "either table settings or reference tables must be specified")
case ms.IsReference && len(ms.TableSettings) > 0:
return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cannot specify both table settings and reference tables")
}

if ms.IsReference {
for _, table := range ms.Tables {
ms.TableSettings = append(ms.TableSettings, &vtctldatapb.TableMaterializeSettings{
Expand Down

0 comments on commit 64802a5

Please sign in to comment.