Skip to content
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

Add Expression verification API signature #927

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions accessors/spanner/expression_verify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package spanneraccessor

import (
"context"
"sync"

spanneradmin "github.com/GoogleCloudPlatform/spanner-migration-tool/accessors/clients/spanner/admin"
"github.com/GoogleCloudPlatform/spanner-migration-tool/internal"
"github.com/GoogleCloudPlatform/spanner-migration-tool/sources/common"
)


type ExpressionVerificationAccessor interface {
//Creates an empty staging database if it does not exist.
CreateStagingDb(ctx context.Context, adminClient spanneradmin.AdminClient, dbURI string) (bool, error)
//Initialize an empty database (or force initializes a non-empty one) with a conv object
InitializeStagingDb(ctx context.Context, adminClient spanneradmin.AdminClient, dbURI string, conv *internal.Conv, force bool) (bool, error)
//Deletes a staging database
DeleteStagingDb(ctx context.Context, adminClient spanneradmin.AdminClient, dbURI string) (bool, error)
//Internal API which verifies an expression by making a call to Spanner
VerifyExpression(ctx context.Context, verificationInput internal.VerificationInput, mutex *sync.Mutex) common.TaskResult[internal.VerificationResult]
//Batch API which parallelizes expression verification calls
BatchVerifyExpressions(ctx context.Context, verificationInputList []internal.VerificationInput) internal.BatchVerificationResult
}

type ExpressionVerificationAccessorImpl struct{}

func (ev *ExpressionVerificationAccessorImpl) CreateStagingDb(ctx context.Context, adminClient spanneradmin.AdminClient, dbURI string) (bool, error) {
return true, nil
}

func (ev *ExpressionVerificationAccessorImpl) InitializeStagingDb(ctx context.Context, adminClient spanneradmin.AdminClient, dbURI string, conv *internal.Conv, force bool) (bool, error) {
return true, nil
}

func (ev *ExpressionVerificationAccessorImpl) DeleteStagingDb(ctx context.Context, adminClient spanneradmin.AdminClient, dbURI string) (bool, error) {
return true, nil
}

func (ev *ExpressionVerificationAccessorImpl) VerifyExpression(ctx context.Context, verificationInput internal.VerificationInput, mutex *sync.Mutex) common.TaskResult[internal.VerificationResult] {
return common.TaskResult[internal.VerificationResult]{}
}

func (ev *ExpressionVerificationAccessorImpl) BatchVerifyExpressions(ctx context.Context, verificationInputList []internal.VerificationInput) (internal.BatchVerificationResult) {
return internal.BatchVerificationResult{}
}




26 changes: 26 additions & 0 deletions internal/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,32 @@ type TableDetails struct {
TableName string `json:TableName`
}

type ExpressionDetail struct {
ReferenceElement ReferenceElement
Expression string
Type string
Metadata map[string]string
}

type ReferenceElement struct {
Id string
Name string
}

type VerificationInput struct {
DbURI string
ExpressionDetail ExpressionDetail
}

type VerificationResult struct {
Result bool
err error
}

type BatchVerificationResult struct {
VerificationResultList []VerificationResult
}

// MakeConv returns a default-configured Conv.
func MakeConv() *Conv {
return &Conv{
Expand Down
Loading