From f45f6f0a7984a94887f5a5be39ee31661ae440fd Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Thu, 4 Apr 2024 22:20:05 +0900 Subject: [PATCH 1/4] all: fix using deprecated io/ioutil package Signed-off-by: Koichi Shiraishi --- cli_test.go | 7 +++---- main.go | 10 +++++----- query_plan_test.go | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cli_test.go b/cli_test.go index a0297df..4d43b9b 100644 --- a/cli_test.go +++ b/cli_test.go @@ -20,7 +20,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "strings" "testing" "time" @@ -164,9 +163,9 @@ func TestReadInteractiveInput(t *testing.T) { } { t.Run(tt.desc, func(t *testing.T) { rl, err := readline.NewEx(&readline.Config{ - Stdin: ioutil.NopCloser(strings.NewReader(tt.input)), - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdin: io.NopCloser(strings.NewReader(tt.input)), + Stdout: io.Discard, + Stderr: io.Discard, }) if err != nil { t.Fatalf("unexpected readline.NewEx() error: %v", err) diff --git a/main.go b/main.go index 5d38593..50917ad 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ package main import ( "fmt" - "io/ioutil" + "io" "os" "os/user" "path/filepath" @@ -105,13 +105,13 @@ func main() { if opts.Execute != "" { input = opts.Execute } else if opts.File == "-" { - b, err := ioutil.ReadAll(os.Stdin) + b, err := io.ReadAll(os.Stdin) if err != nil { exitf("Read from stdin failed: %v", err) } input = string(b) } else if opts.File != "" { - b, err := ioutil.ReadFile(opts.File) + b, err := os.ReadFile(opts.File) if err != nil { exitf("Read from file %v failed: %v", opts.File, err) } @@ -168,13 +168,13 @@ func readCredentialFile(filepath string) ([]byte, error) { if err != nil { return nil, err } - return ioutil.ReadAll(f) + return io.ReadAll(f) } func readStdin() (string, error) { stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice) == 0 { - b, err := ioutil.ReadAll(os.Stdin) + b, err := io.ReadAll(os.Stdin) if err != nil { return "", err } diff --git a/query_plan_test.go b/query_plan_test.go index b47a3df..f60c49f 100644 --- a/query_plan_test.go +++ b/query_plan_test.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "os" "testing" "github.com/google/go-cmp/cmp" @@ -367,7 +367,7 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) { }, } { t.Run(test.title, func(t *testing.T) { - b, err := ioutil.ReadFile(test.file) + b, err := os.ReadFile(test.file) if err != nil { t.Fatal(err) } From 8b5a0a8198e5875957c8e8b7454498657a0fa382 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Thu, 4 Apr 2024 22:21:56 +0900 Subject: [PATCH 2/4] all: fix using deprecated google.golang.org/genproto package Signed-off-by: Koichi Shiraishi --- query_plan_test.go | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/query_plan_test.go b/query_plan_test.go index f60c49f..adbd8e1 100644 --- a/query_plan_test.go +++ b/query_plan_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "google.golang.org/genproto/googleapis/spanner/v1" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/types/known/structpb" @@ -391,20 +390,20 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) { func TestRenderTreeWithStats(t *testing.T) { for _, test := range []struct { title string - plan *spanner.QueryPlan + plan *pb.QueryPlan want []QueryPlanRow }{ { title: "Simple Query", - plan: &spanner.QueryPlan{ - PlanNodes: []*spanner.PlanNode{ + plan: &pb.QueryPlan{ + PlanNodes: []*pb.PlanNode{ { Index: 0, - ChildLinks: []*spanner.PlanNode_ChildLink{ + ChildLinks: []*pb.PlanNode_ChildLink{ {ChildIndex: 1}, }, DisplayName: "Distributed Union", - Kind: spanner.PlanNode_RELATIONAL, + Kind: pb.PlanNode_RELATIONAL, ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, "rows": map[string]interface{}{"total": "9"}, @@ -413,11 +412,11 @@ func TestRenderTreeWithStats(t *testing.T) { }, { Index: 1, - ChildLinks: []*spanner.PlanNode_ChildLink{ + ChildLinks: []*pb.PlanNode_ChildLink{ {ChildIndex: 2}, }, DisplayName: "Distributed Union", - Kind: spanner.PlanNode_RELATIONAL, + Kind: pb.PlanNode_RELATIONAL, Metadata: mustNewStruct(map[string]interface{}{"call_type": "Local"}), ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, @@ -427,11 +426,11 @@ func TestRenderTreeWithStats(t *testing.T) { }, { Index: 2, - ChildLinks: []*spanner.PlanNode_ChildLink{ + ChildLinks: []*pb.PlanNode_ChildLink{ {ChildIndex: 3}, }, DisplayName: "Serialize Result", - Kind: spanner.PlanNode_RELATIONAL, + Kind: pb.PlanNode_RELATIONAL, ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, "rows": map[string]interface{}{"total": "9"}, @@ -441,7 +440,7 @@ func TestRenderTreeWithStats(t *testing.T) { { Index: 3, DisplayName: "Scan", - Kind: spanner.PlanNode_RELATIONAL, + Kind: pb.PlanNode_RELATIONAL, Metadata: mustNewStruct(map[string]interface{}{"scan_type": "IndexScan", "scan_target": "SongsBySingerAlbumSongNameDesc", "Full scan": "true"}), ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, @@ -501,7 +500,7 @@ func TestNodeString(t *testing.T) { want string }{ {"Distributed Union with call_type=Local", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Distributed Union", Metadata: mustNewStruct(map[string]interface{}{ "call_type": "Local", @@ -510,7 +509,7 @@ func TestNodeString(t *testing.T) { }}, "Local Distributed Union", }, {"Scan with scan_type=IndexScan and Full scan=true", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Scan", Metadata: mustNewStruct(map[string]interface{}{ "scan_type": "IndexScan", @@ -519,7 +518,7 @@ func TestNodeString(t *testing.T) { }), }}, "Index Scan (Full scan: true, Index: SongsBySongName)"}, {"Scan with scan_type=TableScan", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Scan", Metadata: mustNewStruct(map[string]interface{}{ "scan_type": "TableScan", @@ -527,7 +526,7 @@ func TestNodeString(t *testing.T) { }), }}, "Table Scan (Table: Songs)"}, {"Scan with scan_type=BatchScan", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Scan", Metadata: mustNewStruct(map[string]interface{}{ "scan_type": "BatchScan", @@ -535,21 +534,21 @@ func TestNodeString(t *testing.T) { }), }}, "Batch Scan (Batch: $v2)"}, {"Sort Limit with call_type=Local", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Sort Limit", Metadata: mustNewStruct(map[string]interface{}{ "call_type": "Local", }), }}, "Local Sort Limit"}, {"Sort Limit with call_type=Global", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Sort Limit", Metadata: mustNewStruct(map[string]interface{}{ "call_type": "Global", }), }}, "Global Sort Limit"}, {"Aggregate with iterator_type=Stream", - &Node{PlanNode: &spanner.PlanNode{ + &Node{PlanNode: &pb.PlanNode{ DisplayName: "Aggregate", Metadata: mustNewStruct(map[string]interface{}{ "iterator_type": "Stream", From 92a0b337dc8bed5282b247595b56444e8caf0108 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Thu, 4 Apr 2024 22:22:28 +0900 Subject: [PATCH 3/4] all: fix using deprecated grpc.WithInsecure() function Signed-off-by: Koichi Shiraishi --- session_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/session_test.go b/session_test.go index eb104ae..ab7b986 100644 --- a/session_test.go +++ b/session_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "google.golang.org/api/option" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/protobuf/testing/protocmp" pb "cloud.google.com/go/spanner/apiv1/spannerpb" @@ -22,7 +23,7 @@ func TestRequestPriority(t *testing.T) { var recorder requestRecorder unaryInterceptor, streamInterceptor := recordRequestsInterceptors(&recorder) opts := []grpc.DialOption{ - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(unaryInterceptor), grpc.WithStreamInterceptor(streamInterceptor), } From 5a49ce5314f74348cc9b94fe64aec8774f89a221 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Thu, 4 Apr 2024 22:26:22 +0900 Subject: [PATCH 4/4] all: unify spannerpb package import alias to sppb Signed-off-by: Koichi Shiraishi --- cli.go | 8 +++--- integration_test.go | 4 +-- main.go | 6 ++--- query_plan.go | 18 ++++++------- query_plan_test.go | 54 ++++++++++++++++++------------------- session.go | 48 ++++++++++++++++----------------- session_test.go | 66 ++++++++++++++++++++++----------------------- statement.go | 30 ++++++++++----------- statement_test.go | 18 ++++++------- 9 files changed, 126 insertions(+), 126 deletions(-) diff --git a/cli.go b/cli.go index 6cc6aa7..824142d 100644 --- a/cli.go +++ b/cli.go @@ -29,7 +29,7 @@ import ( "time" "cloud.google.com/go/spanner" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" "github.com/chzyer/readline" "github.com/olekukonko/tablewriter" "google.golang.org/api/option" @@ -66,7 +66,7 @@ type Cli struct { OutStream io.Writer ErrStream io.Writer Verbose bool - Priority pb.RequestOptions_Priority + Priority sppb.RequestOptions_Priority Endpoint string } @@ -75,7 +75,7 @@ type command struct { Vertical bool } -func NewCli(projectId, instanceId, databaseId, prompt, historyFile string, credential []byte, inStream io.ReadCloser, outStream io.Writer, errStream io.Writer, verbose bool, priority pb.RequestOptions_Priority, role string, endpoint string, directedRead *pb.DirectedReadOptions) (*Cli, error) { +func NewCli(projectId, instanceId, databaseId, prompt, historyFile string, credential []byte, inStream io.ReadCloser, outStream io.Writer, errStream io.Writer, verbose bool, priority sppb.RequestOptions_Priority, role string, endpoint string, directedRead *sppb.DirectedReadOptions) (*Cli, error) { session, err := createSession(projectId, instanceId, databaseId, credential, priority, role, endpoint, directedRead) if err != nil { return nil, err @@ -310,7 +310,7 @@ func (c *Cli) getInterpolatedPrompt() string { return prompt } -func createSession(projectId string, instanceId string, databaseId string, credential []byte, priority pb.RequestOptions_Priority, role string, endpoint string, directedRead *pb.DirectedReadOptions) (*Session, error) { +func createSession(projectId string, instanceId string, databaseId string, credential []byte, priority sppb.RequestOptions_Priority, role string, endpoint string, directedRead *sppb.DirectedReadOptions) (*Session, error) { var opts []option.ClientOption if credential != nil { opts = append(opts, option.WithCredentialsJSON(credential)) diff --git a/integration_test.go b/integration_test.go index 491a15b..e7f38fe 100644 --- a/integration_test.go +++ b/integration_test.go @@ -32,7 +32,7 @@ import ( "google.golang.org/api/option" adminpb "cloud.google.com/go/spanner/admin/database/apiv1/databasepb" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" ) const ( @@ -85,7 +85,7 @@ func setup(t *testing.T, ctx context.Context, dmls []string) (*Session, string, if testCredential != "" { options = append(options, option.WithCredentialsJSON([]byte(testCredential))) } - session, err := NewSession(testProjectId, testInstanceId, testDatabaseId, pb.RequestOptions_PRIORITY_UNSPECIFIED, "", nil, options...) + session, err := NewSession(testProjectId, testInstanceId, testDatabaseId, sppb.RequestOptions_PRIORITY_UNSPECIFIED, "", nil, options...) if err != nil { t.Fatalf("failed to create test session: err=%s", err) } diff --git a/main.go b/main.go index 50917ad..9bbbecf 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ import ( "os/user" "path/filepath" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" flags "github.com/jessevdk/go-flags" ) @@ -78,7 +78,7 @@ func main() { } } - var priority pb.RequestOptions_Priority + var priority sppb.RequestOptions_Priority if opts.Priority != "" { var err error priority, err = parsePriority(opts.Priority) @@ -87,7 +87,7 @@ func main() { } } - var directedRead *pb.DirectedReadOptions + var directedRead *sppb.DirectedReadOptions if opts.DirectedRead != "" { var err error directedRead, err = parseDirectedReadOption(opts.DirectedRead) diff --git a/query_plan.go b/query_plan.go index 6aced03..b8e8232 100644 --- a/query_plan.go +++ b/query_plan.go @@ -22,7 +22,7 @@ import ( "sort" "strings" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" "github.com/xlab/treeprint" "google.golang.org/protobuf/types/known/structpb" ) @@ -42,7 +42,7 @@ type Link struct { } type Node struct { - PlanNode *pb.PlanNode + PlanNode *sppb.PlanNode Children []*Link } @@ -80,12 +80,12 @@ type queryPlanNodeWithStatsTyped struct { LinkType string `json:"link_type"` } -func BuildQueryPlanTree(plan *pb.QueryPlan, idx int32) *Node { +func BuildQueryPlanTree(plan *sppb.QueryPlan, idx int32) *Node { if len(plan.PlanNodes) == 0 { return &Node{} } - nodeMap := map[int32]*pb.PlanNode{} + nodeMap := map[int32]*sppb.PlanNode{} for _, node := range plan.PlanNodes { nodeMap[node.Index] = node } @@ -120,7 +120,7 @@ type QueryPlanRow struct { Predicates []string } -func isPredicate(planNodes []*pb.PlanNode, childLink *pb.PlanNode_ChildLink) bool { +func isPredicate(planNodes []*sppb.PlanNode, childLink *sppb.PlanNode_ChildLink) bool { // Known predicates are Condition(Filter/Hash Join) or Seek Condition/Residual Condition(FilterScan) or Split Range(Distributed Union). // Agg is a Function but not a predicate. child := planNodes[childLink.ChildIndex] @@ -133,7 +133,7 @@ func isPredicate(planNodes []*pb.PlanNode, childLink *pb.PlanNode_ChildLink) boo return false } -func (n *Node) RenderTreeWithStats(planNodes []*pb.PlanNode) ([]QueryPlanRow, error) { +func (n *Node) RenderTreeWithStats(planNodes []*sppb.PlanNode) ([]QueryPlanRow, error) { tree := treeprint.New() renderTreeWithStats(tree, "", n) var result []QueryPlanRow @@ -239,7 +239,7 @@ func (n *Node) String() string { func renderTreeWithStats(tree treeprint.Tree, linkType string, node *Node) { // Scalar operator is rendered if and only if it is linked as Scalar type(Scalar/Array Subquery) - if node.PlanNode.GetKind() == pb.PlanNode_SCALAR && linkType != "Scalar" { + if node.PlanNode.GetKind() == sppb.PlanNode_SCALAR && linkType != "Scalar" { return } @@ -274,13 +274,13 @@ func renderTreeWithStats(tree treeprint.Tree, linkType string, node *Node) { } } -func getMaxRelationalNodeID(plan *pb.QueryPlan) int32 { +func getMaxRelationalNodeID(plan *sppb.QueryPlan) int32 { var maxRelationalNodeID int32 // We assume that plan_nodes[] is pre-sorted in ascending order. // See QueryPlan.plan_nodes[] in the document. // https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1?hl=en#google.spanner.v1.QueryPlan.FIELDS.repeated.google.spanner.v1.PlanNode.google.spanner.v1.QueryPlan.plan_nodes for _, planNode := range plan.GetPlanNodes() { - if planNode.GetKind() == pb.PlanNode_RELATIONAL { + if planNode.GetKind() == sppb.PlanNode_RELATIONAL { maxRelationalNodeID = planNode.Index } } diff --git a/query_plan_test.go b/query_plan_test.go index adbd8e1..3bf0037 100644 --- a/query_plan_test.go +++ b/query_plan_test.go @@ -8,7 +8,7 @@ import ( "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/types/known/structpb" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" ) func mustNewStruct(m map[string]interface{}) *structpb.Struct { @@ -370,7 +370,7 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) { if err != nil { t.Fatal(err) } - var plan pb.QueryPlan + var plan sppb.QueryPlan err = protojson.Unmarshal(b, &plan) if err != nil { t.Fatal(err) @@ -390,20 +390,20 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) { func TestRenderTreeWithStats(t *testing.T) { for _, test := range []struct { title string - plan *pb.QueryPlan + plan *sppb.QueryPlan want []QueryPlanRow }{ { title: "Simple Query", - plan: &pb.QueryPlan{ - PlanNodes: []*pb.PlanNode{ + plan: &sppb.QueryPlan{ + PlanNodes: []*sppb.PlanNode{ { Index: 0, - ChildLinks: []*pb.PlanNode_ChildLink{ + ChildLinks: []*sppb.PlanNode_ChildLink{ {ChildIndex: 1}, }, DisplayName: "Distributed Union", - Kind: pb.PlanNode_RELATIONAL, + Kind: sppb.PlanNode_RELATIONAL, ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, "rows": map[string]interface{}{"total": "9"}, @@ -412,11 +412,11 @@ func TestRenderTreeWithStats(t *testing.T) { }, { Index: 1, - ChildLinks: []*pb.PlanNode_ChildLink{ + ChildLinks: []*sppb.PlanNode_ChildLink{ {ChildIndex: 2}, }, DisplayName: "Distributed Union", - Kind: pb.PlanNode_RELATIONAL, + Kind: sppb.PlanNode_RELATIONAL, Metadata: mustNewStruct(map[string]interface{}{"call_type": "Local"}), ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, @@ -426,11 +426,11 @@ func TestRenderTreeWithStats(t *testing.T) { }, { Index: 2, - ChildLinks: []*pb.PlanNode_ChildLink{ + ChildLinks: []*sppb.PlanNode_ChildLink{ {ChildIndex: 3}, }, DisplayName: "Serialize Result", - Kind: pb.PlanNode_RELATIONAL, + Kind: sppb.PlanNode_RELATIONAL, ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, "rows": map[string]interface{}{"total": "9"}, @@ -440,7 +440,7 @@ func TestRenderTreeWithStats(t *testing.T) { { Index: 3, DisplayName: "Scan", - Kind: pb.PlanNode_RELATIONAL, + Kind: sppb.PlanNode_RELATIONAL, Metadata: mustNewStruct(map[string]interface{}{"scan_type": "IndexScan", "scan_target": "SongsBySingerAlbumSongNameDesc", "Full scan": "true"}), ExecutionStats: mustNewStruct(map[string]interface{}{ "latency": map[string]interface{}{"total": "1", "unit": "msec"}, @@ -500,7 +500,7 @@ func TestNodeString(t *testing.T) { want string }{ {"Distributed Union with call_type=Local", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Distributed Union", Metadata: mustNewStruct(map[string]interface{}{ "call_type": "Local", @@ -509,7 +509,7 @@ func TestNodeString(t *testing.T) { }}, "Local Distributed Union", }, {"Scan with scan_type=IndexScan and Full scan=true", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Scan", Metadata: mustNewStruct(map[string]interface{}{ "scan_type": "IndexScan", @@ -518,7 +518,7 @@ func TestNodeString(t *testing.T) { }), }}, "Index Scan (Full scan: true, Index: SongsBySongName)"}, {"Scan with scan_type=TableScan", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Scan", Metadata: mustNewStruct(map[string]interface{}{ "scan_type": "TableScan", @@ -526,7 +526,7 @@ func TestNodeString(t *testing.T) { }), }}, "Table Scan (Table: Songs)"}, {"Scan with scan_type=BatchScan", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Scan", Metadata: mustNewStruct(map[string]interface{}{ "scan_type": "BatchScan", @@ -534,21 +534,21 @@ func TestNodeString(t *testing.T) { }), }}, "Batch Scan (Batch: $v2)"}, {"Sort Limit with call_type=Local", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Sort Limit", Metadata: mustNewStruct(map[string]interface{}{ "call_type": "Local", }), }}, "Local Sort Limit"}, {"Sort Limit with call_type=Global", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Sort Limit", Metadata: mustNewStruct(map[string]interface{}{ "call_type": "Global", }), }}, "Global Sort Limit"}, {"Aggregate with iterator_type=Stream", - &Node{PlanNode: &pb.PlanNode{ + &Node{PlanNode: &sppb.PlanNode{ DisplayName: "Aggregate", Metadata: mustNewStruct(map[string]interface{}{ "iterator_type": "Stream", @@ -564,18 +564,18 @@ func TestNodeString(t *testing.T) { func TestGetMaxRelationalNodeID(t *testing.T) { for _, tt := range []struct { desc string - input *pb.QueryPlan + input *sppb.QueryPlan want int32 }{ { desc: "pre-sorted order", - input: &pb.QueryPlan{ - PlanNodes: []*pb.PlanNode{ - {Index: 0, DisplayName: "Scalar Subquery", Kind: pb.PlanNode_SCALAR}, - {Index: 1, DisplayName: "Index Scan", Kind: pb.PlanNode_RELATIONAL}, - {Index: 2, DisplayName: "Index Scan", Kind: pb.PlanNode_RELATIONAL}, - {Index: 3, DisplayName: "Index Scan", Kind: pb.PlanNode_RELATIONAL}, - {Index: 4, DisplayName: "Constant", Kind: pb.PlanNode_SCALAR}, // This is not visible + input: &sppb.QueryPlan{ + PlanNodes: []*sppb.PlanNode{ + {Index: 0, DisplayName: "Scalar Subquery", Kind: sppb.PlanNode_SCALAR}, + {Index: 1, DisplayName: "Index Scan", Kind: sppb.PlanNode_RELATIONAL}, + {Index: 2, DisplayName: "Index Scan", Kind: sppb.PlanNode_RELATIONAL}, + {Index: 3, DisplayName: "Index Scan", Kind: sppb.PlanNode_RELATIONAL}, + {Index: 4, DisplayName: "Constant", Kind: sppb.PlanNode_SCALAR}, // This is not visible }, }, want: 3, diff --git a/session.go b/session.go index ccd34bd..8ff1e76 100644 --- a/session.go +++ b/session.go @@ -29,7 +29,7 @@ import ( "google.golang.org/grpc/codes" adminapi "cloud.google.com/go/spanner/admin/database/apiv1" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" ) var defaultClientConfig = spanner.ClientConfig{ @@ -44,7 +44,7 @@ var defaultClientOpts = []option.ClientOption{ } // Use MEDIUM priority not to disturb regular workloads on the database. -const defaultPriority = pb.RequestOptions_PRIORITY_MEDIUM +const defaultPriority = sppb.RequestOptions_PRIORITY_MEDIUM type Session struct { projectId string @@ -54,21 +54,21 @@ type Session struct { adminClient *adminapi.DatabaseAdminClient clientConfig spanner.ClientConfig clientOpts []option.ClientOption - defaultPriority pb.RequestOptions_Priority - directedRead *pb.DirectedReadOptions + defaultPriority sppb.RequestOptions_Priority + directedRead *sppb.DirectedReadOptions tc *transactionContext tcMutex sync.Mutex // Guard a critical section for transaction. } type transactionContext struct { tag string - priority pb.RequestOptions_Priority + priority sppb.RequestOptions_Priority sendHeartbeat bool // Becomes true only after a user-driven query is executed on the transaction. rwTxn *spanner.ReadWriteStmtBasedTransaction roTxn *spanner.ReadOnlyTransaction } -func NewSession(projectId string, instanceId string, databaseId string, priority pb.RequestOptions_Priority, role string, directedRead *pb.DirectedReadOptions, opts ...option.ClientOption) (*Session, error) { +func NewSession(projectId string, instanceId string, databaseId string, priority sppb.RequestOptions_Priority, role string, directedRead *sppb.DirectedReadOptions, opts ...option.ClientOption) (*Session, error) { ctx := context.Background() dbPath := fmt.Sprintf("projects/%s/instances/%s/databases/%s", projectId, instanceId, databaseId) clientConfig := defaultClientConfig @@ -85,7 +85,7 @@ func NewSession(projectId string, instanceId string, databaseId string, priority return nil, err } - if priority == pb.RequestOptions_PRIORITY_UNSPECIFIED { + if priority == sppb.RequestOptions_PRIORITY_UNSPECIFIED { priority = defaultPriority } @@ -116,13 +116,13 @@ func (s *Session) InReadOnlyTransaction() bool { } // BeginReadWriteTransaction starts read-write transaction. -func (s *Session) BeginReadWriteTransaction(ctx context.Context, priority pb.RequestOptions_Priority, tag string) error { +func (s *Session) BeginReadWriteTransaction(ctx context.Context, priority sppb.RequestOptions_Priority, tag string) error { if s.InReadWriteTransaction() { return errors.New("read-write transaction is already running") } // Use session's priority if transaction priority is not set. - if priority == pb.RequestOptions_PRIORITY_UNSPECIFIED { + if priority == sppb.RequestOptions_PRIORITY_UNSPECIFIED { priority = s.defaultPriority } @@ -172,7 +172,7 @@ func (s *Session) RollbackReadWriteTransaction(ctx context.Context) error { } // BeginReadOnlyTransaction starts read-only transaction and returns the snapshot timestamp for the transaction if successful. -func (s *Session) BeginReadOnlyTransaction(ctx context.Context, typ timestampBoundType, staleness time.Duration, timestamp time.Time, priority pb.RequestOptions_Priority, tag string) (time.Time, error) { +func (s *Session) BeginReadOnlyTransaction(ctx context.Context, typ timestampBoundType, staleness time.Duration, timestamp time.Time, priority sppb.RequestOptions_Priority, tag string) (time.Time, error) { if s.InReadOnlyTransaction() { return time.Time{}, errors.New("read-only transaction is already running") } @@ -188,7 +188,7 @@ func (s *Session) BeginReadOnlyTransaction(ctx context.Context, typ timestampBou } // Use session's priority if transaction priority is not set. - if priority == pb.RequestOptions_PRIORITY_UNSPECIFIED { + if priority == sppb.RequestOptions_PRIORITY_UNSPECIFIED { priority = s.defaultPriority } @@ -224,7 +224,7 @@ func (s *Session) CloseReadOnlyTransaction() error { // RunQueryWithStats executes a statement with stats either on the running transaction or on the temporal read-only transaction. // It returns row iterator and read-only transaction if the statement was executed on the read-only transaction. func (s *Session) RunQueryWithStats(ctx context.Context, stmt spanner.Statement) (*spanner.RowIterator, *spanner.ReadOnlyTransaction) { - mode := pb.ExecuteSqlRequest_PROFILE + mode := sppb.ExecuteSqlRequest_PROFILE opts := spanner.QueryOptions{ Mode: &mode, Priority: s.currentPriority(), @@ -242,8 +242,8 @@ func (s *Session) RunQuery(ctx context.Context, stmt spanner.Statement) (*spanne } // RunAnalyzeQuery analyzes a statement either on the running transaction or on the temporal read-only transaction. -func (s *Session) RunAnalyzeQuery(ctx context.Context, stmt spanner.Statement) (*pb.QueryPlan, error) { - mode := pb.ExecuteSqlRequest_PLAN +func (s *Session) RunAnalyzeQuery(ctx context.Context, stmt spanner.Statement) (*sppb.QueryPlan, error) { + mode := sppb.ExecuteSqlRequest_PLAN opts := spanner.QueryOptions{ Mode: &mode, Priority: s.currentPriority(), @@ -357,7 +357,7 @@ func (s *Session) RecreateClient() error { return nil } -func (s *Session) currentPriority() pb.RequestOptions_Priority { +func (s *Session) currentPriority() sppb.RequestOptions_Priority { if s.tc != nil { return s.tc.priority } @@ -389,7 +389,7 @@ func (s *Session) startHeartbeat() { } } -func heartbeat(txn *spanner.ReadWriteStmtBasedTransaction, priority pb.RequestOptions_Priority) error { +func heartbeat(txn *spanner.ReadWriteStmtBasedTransaction, priority sppb.RequestOptions_Priority) error { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() iter := txn.QueryWithOptions(ctx, spanner.NewStatement("SELECT 1"), spanner.QueryOptions{Priority: priority}) @@ -398,31 +398,31 @@ func heartbeat(txn *spanner.ReadWriteStmtBasedTransaction, priority pb.RequestOp return err } -func parseDirectedReadOption(directedReadOptionText string) (*pb.DirectedReadOptions, error) { +func parseDirectedReadOption(directedReadOptionText string) (*sppb.DirectedReadOptions, error) { directedReadOption := strings.Split(directedReadOptionText, ":") if len(directedReadOption) > 2 { return nil, fmt.Errorf("directed read option must be in the form of :, but got %q", directedReadOptionText) } - replicaSelection := pb.DirectedReadOptions_ReplicaSelection{ + replicaSelection := sppb.DirectedReadOptions_ReplicaSelection{ Location: directedReadOption[0], } if len(directedReadOption) == 2 { switch strings.ToUpper(directedReadOption[1]) { case "READ_ONLY": - replicaSelection.Type = pb.DirectedReadOptions_ReplicaSelection_READ_ONLY + replicaSelection.Type = sppb.DirectedReadOptions_ReplicaSelection_READ_ONLY case "READ_WRITE": - replicaSelection.Type = pb.DirectedReadOptions_ReplicaSelection_READ_WRITE + replicaSelection.Type = sppb.DirectedReadOptions_ReplicaSelection_READ_WRITE default: return nil, fmt.Errorf(" must be either READ_WRITE or READ_ONLY, but got %q", directedReadOption[1]) } } - return &pb.DirectedReadOptions{ - Replicas: &pb.DirectedReadOptions_IncludeReplicas_{ - IncludeReplicas: &pb.DirectedReadOptions_IncludeReplicas{ - ReplicaSelections: []*pb.DirectedReadOptions_ReplicaSelection{&replicaSelection}, + return &sppb.DirectedReadOptions{ + Replicas: &sppb.DirectedReadOptions_IncludeReplicas_{ + IncludeReplicas: &sppb.DirectedReadOptions_IncludeReplicas{ + ReplicaSelections: []*sppb.DirectedReadOptions_ReplicaSelection{&replicaSelection}, AutoFailoverDisabled: true, }, }, diff --git a/session_test.go b/session_test.go index ab7b986..69fe01e 100644 --- a/session_test.go +++ b/session_test.go @@ -14,7 +14,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/protobuf/testing/protocmp" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" ) func TestRequestPriority(t *testing.T) { @@ -35,33 +35,33 @@ func TestRequestPriority(t *testing.T) { for _, test := range []struct { desc string - sessionPriority pb.RequestOptions_Priority - transactionPriority pb.RequestOptions_Priority - want pb.RequestOptions_Priority + sessionPriority sppb.RequestOptions_Priority + transactionPriority sppb.RequestOptions_Priority + want sppb.RequestOptions_Priority }{ { desc: "use default MEDIUM priority", - sessionPriority: pb.RequestOptions_PRIORITY_UNSPECIFIED, - transactionPriority: pb.RequestOptions_PRIORITY_UNSPECIFIED, - want: pb.RequestOptions_PRIORITY_MEDIUM, + sessionPriority: sppb.RequestOptions_PRIORITY_UNSPECIFIED, + transactionPriority: sppb.RequestOptions_PRIORITY_UNSPECIFIED, + want: sppb.RequestOptions_PRIORITY_MEDIUM, }, { desc: "use session priority", - sessionPriority: pb.RequestOptions_PRIORITY_LOW, - transactionPriority: pb.RequestOptions_PRIORITY_UNSPECIFIED, - want: pb.RequestOptions_PRIORITY_LOW, + sessionPriority: sppb.RequestOptions_PRIORITY_LOW, + transactionPriority: sppb.RequestOptions_PRIORITY_UNSPECIFIED, + want: sppb.RequestOptions_PRIORITY_LOW, }, { desc: "use transaction priority", - sessionPriority: pb.RequestOptions_PRIORITY_UNSPECIFIED, - transactionPriority: pb.RequestOptions_PRIORITY_HIGH, - want: pb.RequestOptions_PRIORITY_HIGH, + sessionPriority: sppb.RequestOptions_PRIORITY_UNSPECIFIED, + transactionPriority: sppb.RequestOptions_PRIORITY_HIGH, + want: sppb.RequestOptions_PRIORITY_HIGH, }, { desc: "transaction priority takes over session priority", - sessionPriority: pb.RequestOptions_PRIORITY_HIGH, - transactionPriority: pb.RequestOptions_PRIORITY_LOW, - want: pb.RequestOptions_PRIORITY_LOW, + sessionPriority: sppb.RequestOptions_PRIORITY_HIGH, + transactionPriority: sppb.RequestOptions_PRIORITY_LOW, + want: sppb.RequestOptions_PRIORITY_LOW, }, } { t.Run(test.desc, func(t *testing.T) { @@ -106,11 +106,11 @@ func TestRequestPriority(t *testing.T) { // Check request priority. for _, r := range recorder.requests { switch v := r.(type) { - case *pb.ExecuteSqlRequest: + case *sppb.ExecuteSqlRequest: if got := v.GetRequestOptions().GetPriority(); got != test.want { t.Errorf("priority mismatch: got = %v, want = %v", got, test.want) } - case *pb.CommitRequest: + case *sppb.CommitRequest: if got := v.GetRequestOptions().GetPriority(); got != test.want { t.Errorf("priority mismatch: got = %v, want = %v", got, test.want) } @@ -124,15 +124,15 @@ func TestParseDirectedReadOption(t *testing.T) { for _, tt := range []struct { desc string option string - want *pb.DirectedReadOptions + want *sppb.DirectedReadOptions }{ { desc: "use directed read location option only", option: "us-central1", - want: &pb.DirectedReadOptions{ - Replicas: &pb.DirectedReadOptions_IncludeReplicas_{ - IncludeReplicas: &pb.DirectedReadOptions_IncludeReplicas{ - ReplicaSelections: []*pb.DirectedReadOptions_ReplicaSelection{ + want: &sppb.DirectedReadOptions{ + Replicas: &sppb.DirectedReadOptions_IncludeReplicas_{ + IncludeReplicas: &sppb.DirectedReadOptions_IncludeReplicas{ + ReplicaSelections: []*sppb.DirectedReadOptions_ReplicaSelection{ { Location: "us-central1", }, @@ -145,13 +145,13 @@ func TestParseDirectedReadOption(t *testing.T) { { desc: "use directed read location and type option (READ_ONLY)", option: "us-central1:READ_ONLY", - want: &pb.DirectedReadOptions{ - Replicas: &pb.DirectedReadOptions_IncludeReplicas_{ - IncludeReplicas: &pb.DirectedReadOptions_IncludeReplicas{ - ReplicaSelections: []*pb.DirectedReadOptions_ReplicaSelection{ + want: &sppb.DirectedReadOptions{ + Replicas: &sppb.DirectedReadOptions_IncludeReplicas_{ + IncludeReplicas: &sppb.DirectedReadOptions_IncludeReplicas{ + ReplicaSelections: []*sppb.DirectedReadOptions_ReplicaSelection{ { Location: "us-central1", - Type: pb.DirectedReadOptions_ReplicaSelection_READ_ONLY, + Type: sppb.DirectedReadOptions_ReplicaSelection_READ_ONLY, }, }, AutoFailoverDisabled: true, @@ -162,13 +162,13 @@ func TestParseDirectedReadOption(t *testing.T) { { desc: "use directed read location and type option (READ_WRITE)", option: "us-central1:READ_WRITE", - want: &pb.DirectedReadOptions{ - Replicas: &pb.DirectedReadOptions_IncludeReplicas_{ - IncludeReplicas: &pb.DirectedReadOptions_IncludeReplicas{ - ReplicaSelections: []*pb.DirectedReadOptions_ReplicaSelection{ + want: &sppb.DirectedReadOptions{ + Replicas: &sppb.DirectedReadOptions_IncludeReplicas_{ + IncludeReplicas: &sppb.DirectedReadOptions_IncludeReplicas{ + ReplicaSelections: []*sppb.DirectedReadOptions_ReplicaSelection{ { Location: "us-central1", - Type: pb.DirectedReadOptions_ReplicaSelection_READ_WRITE, + Type: sppb.DirectedReadOptions_ReplicaSelection_READ_WRITE, }, }, AutoFailoverDisabled: true, diff --git a/statement.go b/statement.go index fd7539d..b96c3de 100644 --- a/statement.go +++ b/statement.go @@ -27,7 +27,7 @@ import ( "cloud.google.com/go/spanner" adminpb "cloud.google.com/go/spanner/admin/database/apiv1/databasepb" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" "google.golang.org/api/iterator" "google.golang.org/grpc/codes" ) @@ -60,7 +60,7 @@ type Result struct { IsMutation bool Timestamp time.Time ForceVerbose bool - CommitStats *pb.CommitResponse_CommitStats + CommitStats *sppb.CommitResponse_CommitStats } type Row struct { @@ -571,15 +571,15 @@ func (s *ExplainAnalyzeStatement) Execute(ctx context.Context, session *Session) return result, nil } -func processPlanWithStats(plan *pb.QueryPlan) (rows []Row, predicates []string, err error) { +func processPlanWithStats(plan *sppb.QueryPlan) (rows []Row, predicates []string, err error) { return processPlanImpl(plan, true) } -func processPlanWithoutStats(plan *pb.QueryPlan) (rows []Row, predicates []string, err error) { +func processPlanWithoutStats(plan *sppb.QueryPlan) (rows []Row, predicates []string, err error) { return processPlanImpl(plan, false) } -func processPlanImpl(plan *pb.QueryPlan, withStats bool) (rows []Row, predicates []string, err error) { +func processPlanImpl(plan *sppb.QueryPlan, withStats bool) (rows []Row, predicates []string, err error) { planNodes := plan.GetPlanNodes() maxWidthOfNodeID := len(fmt.Sprint(getMaxRelationalNodeID(plan))) widthOfNodeIDWithIndicator := maxWidthOfNodeID + 1 @@ -823,7 +823,7 @@ type ExplainDmlStatement struct { } func (s *ExplainDmlStatement) Execute(ctx context.Context, session *Session) (*Result, error) { - _, timestamp, queryPlan, err := runInNewOrExistRwTxForExplain(ctx, session, func() (int64, *pb.QueryPlan, error) { + _, timestamp, queryPlan, err := runInNewOrExistRwTxForExplain(ctx, session, func() (int64, *sppb.QueryPlan, error) { plan, err := session.RunAnalyzeQuery(ctx, spanner.NewStatement(s.Dml)) return 0, plan, err }) @@ -854,7 +854,7 @@ type ExplainAnalyzeDmlStatement struct { func (s *ExplainAnalyzeDmlStatement) Execute(ctx context.Context, session *Session) (*Result, error) { stmt := spanner.NewStatement(s.Dml) - affectedRows, timestamp, queryPlan, err := runInNewOrExistRwTxForExplain(ctx, session, func() (int64, *pb.QueryPlan, error) { + affectedRows, timestamp, queryPlan, err := runInNewOrExistRwTxForExplain(ctx, session, func() (int64, *sppb.QueryPlan, error) { iter, _ := session.RunQueryWithStats(ctx, stmt) defer iter.Stop() err := iter.Do(func(r *spanner.Row) error { return nil }) @@ -886,7 +886,7 @@ func (s *ExplainAnalyzeDmlStatement) Execute(ctx context.Context, session *Sessi // runInNewOrExistRwTxForExplain is a helper function for ExplainDmlStatement and ExplainAnalyzeDmlStatement. // It execute a function in the current RW transaction or an implicit RW transaction. -func runInNewOrExistRwTxForExplain(ctx context.Context, session *Session, f func() (affected int64, plan *pb.QueryPlan, err error)) (affected int64, ts time.Time, plan *pb.QueryPlan, err error) { +func runInNewOrExistRwTxForExplain(ctx context.Context, session *Session, f func() (affected int64, plan *sppb.QueryPlan, err error)) (affected int64, ts time.Time, plan *sppb.QueryPlan, err error) { if session.InReadWriteTransaction() { affected, plan, err := f() if err != nil { @@ -921,7 +921,7 @@ func runInNewOrExistRwTxForExplain(ctx context.Context, session *Session, f func } type BeginRwStatement struct { - Priority pb.RequestOptions_Priority + Priority sppb.RequestOptions_Priority Tag string } @@ -1010,7 +1010,7 @@ type BeginRoStatement struct { TimestampBoundType timestampBoundType Staleness time.Duration Timestamp time.Time - Priority pb.RequestOptions_Priority + Priority sppb.RequestOptions_Priority Tag string } @@ -1108,15 +1108,15 @@ type UseStatement struct { NopStatement } -func parsePriority(priority string) (pb.RequestOptions_Priority, error) { +func parsePriority(priority string) (sppb.RequestOptions_Priority, error) { switch strings.ToUpper(priority) { case "HIGH": - return pb.RequestOptions_PRIORITY_HIGH, nil + return sppb.RequestOptions_PRIORITY_HIGH, nil case "MEDIUM": - return pb.RequestOptions_PRIORITY_MEDIUM, nil + return sppb.RequestOptions_PRIORITY_MEDIUM, nil case "LOW": - return pb.RequestOptions_PRIORITY_LOW, nil + return sppb.RequestOptions_PRIORITY_LOW, nil default: - return pb.RequestOptions_PRIORITY_UNSPECIFIED, fmt.Errorf("invalid priority: %q", priority) + return sppb.RequestOptions_PRIORITY_UNSPECIFIED, fmt.Errorf("invalid priority: %q", priority) } } diff --git a/statement_test.go b/statement_test.go index 8f3b2cf..3f76925 100644 --- a/statement_test.go +++ b/statement_test.go @@ -24,7 +24,7 @@ import ( "github.com/google/go-cmp/cmp" - pb "cloud.google.com/go/spanner/apiv1/spannerpb" + sppb "cloud.google.com/go/spanner/apiv1/spannerpb" ) func TestBuildStatement(t *testing.T) { @@ -255,14 +255,14 @@ func TestBuildStatement(t *testing.T) { desc: "BEGIN PRIORITY statement", input: "BEGIN PRIORITY MEDIUM", want: &BeginRwStatement{ - Priority: pb.RequestOptions_PRIORITY_MEDIUM, + Priority: sppb.RequestOptions_PRIORITY_MEDIUM, }, }, { desc: "BEGIN RW PRIORITY statement", input: "BEGIN RW PRIORITY LOW", want: &BeginRwStatement{ - Priority: pb.RequestOptions_PRIORITY_LOW, + Priority: sppb.RequestOptions_PRIORITY_LOW, }, }, { @@ -283,7 +283,7 @@ func TestBuildStatement(t *testing.T) { desc: "BEGIN PRIORITY statement with TAG", input: "BEGIN PRIORITY MEDIUM TAG app=spanner-cli,env=test", want: &BeginRwStatement{ - Priority: pb.RequestOptions_PRIORITY_MEDIUM, + Priority: sppb.RequestOptions_PRIORITY_MEDIUM, Tag: "app=spanner-cli,env=test", }, }, @@ -305,7 +305,7 @@ func TestBuildStatement(t *testing.T) { desc: "BEGIN PRIORITY statement with TAG whitespace", input: "BEGIN PRIORITY MEDIUM TAG app=spanner-cli env=test", want: &BeginRwStatement{ - Priority: pb.RequestOptions_PRIORITY_MEDIUM, + Priority: sppb.RequestOptions_PRIORITY_MEDIUM, Tag: "app=spanner-cli env=test", }, }, @@ -335,7 +335,7 @@ func TestBuildStatement(t *testing.T) { { desc: "BEGIN RO PRIORITY statement", input: "BEGIN RO PRIORITY LOW", - want: &BeginRoStatement{TimestampBoundType: strong, Priority: pb.RequestOptions_PRIORITY_LOW}, + want: &BeginRoStatement{TimestampBoundType: strong, Priority: sppb.RequestOptions_PRIORITY_LOW}, }, { desc: "BEGIN RO staleness with PRIORITY statement", @@ -343,7 +343,7 @@ func TestBuildStatement(t *testing.T) { want: &BeginRoStatement{ Staleness: time.Duration(10 * time.Second), TimestampBoundType: exactStaleness, - Priority: pb.RequestOptions_PRIORITY_HIGH, + Priority: sppb.RequestOptions_PRIORITY_HIGH, }, }, { @@ -378,7 +378,7 @@ func TestBuildStatement(t *testing.T) { input: "BEGIN RO PRIORITY LOW TAG app=spanner-cli,env=test", want: &BeginRoStatement{ TimestampBoundType: strong, - Priority: pb.RequestOptions_PRIORITY_LOW, + Priority: sppb.RequestOptions_PRIORITY_LOW, Tag: "app=spanner-cli,env=test", }, }, @@ -388,7 +388,7 @@ func TestBuildStatement(t *testing.T) { want: &BeginRoStatement{ Staleness: time.Duration(10 * time.Second), TimestampBoundType: exactStaleness, - Priority: pb.RequestOptions_PRIORITY_HIGH, + Priority: sppb.RequestOptions_PRIORITY_HIGH, Tag: "app=spanner-cli,env=test", }, },