Skip to content

Commit

Permalink
Merge pull request #99 from rugamaga/update-memefish-dependency
Browse files Browse the repository at this point in the history
Update github.com/cloudspannerecosystem/memefish dependency
  • Loading branch information
kazegusuri authored Jan 12, 2024
2 parents 08dcbc3 + a8b083a commit 3a28861
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 42 deletions.
10 changes: 5 additions & 5 deletions fake/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
lropb "cloud.google.com/go/longrunning/autogen/longrunningpb"
adminv1pb "cloud.google.com/go/spanner/admin/database/apiv1/databasepb"
spannerpb "cloud.google.com/go/spanner/apiv1/spannerpb"
"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/pkg/parser"
"github.com/cloudspannerecosystem/memefish/pkg/token"
"github.com/cloudspannerecosystem/memefish"
"github.com/cloudspannerecosystem/memefish/ast"
"github.com/cloudspannerecosystem/memefish/token"
"github.com/gcpug/handy-spanner/server"
"google.golang.org/grpc"
channelzsvc "google.golang.org/grpc/channelz/service"
Expand Down Expand Up @@ -113,8 +113,8 @@ func (s *Server) ParseAndApplyDDL(ctx context.Context, databaseName string, r io
return err
}

ddl, err := (&parser.Parser{
Lexer: &parser.Lexer{
ddl, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: string(b)},
},
}).ParseDDLs()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
cloud.google.com/go/iam v1.1.2
cloud.google.com/go/longrunning v0.5.1
cloud.google.com/go/spanner v1.50.0
github.com/cloudspannerecosystem/memefish v0.0.0-20230403015737-24c8a514b9e7
github.com/cloudspannerecosystem/memefish v0.0.0-20231128072053-0a1141e8eb65
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudspannerecosystem/memefish v0.0.0-20230403015737-24c8a514b9e7 h1:DK2bE+VunkY4DrCWzn8TNcfwXlfCVCRCt08NFiFRg70=
github.com/cloudspannerecosystem/memefish v0.0.0-20230403015737-24c8a514b9e7/go.mod h1:nfEJK986tmIKMHs6i62pQecA5F6N0N67NsofayZEVKo=
github.com/cloudspannerecosystem/memefish v0.0.0-20231128072053-0a1141e8eb65 h1:Rg9tANZcL6gdZlY1W5TeWMD4pIQN63qkAhS+HhjhbPA=
github.com/cloudspannerecosystem/memefish v0.0.0-20231128072053-0a1141e8eb65/go.mod h1:Q40NmYZbmaw9ay7p94ng9NNBuX1N+4OK3cSjN4q5tPM=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe h1:QQ3GSy+MqSHxm/d8nCtnAiZdYFd45cYZPs8vOOIYKfk=
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
Expand Down
2 changes: 1 addition & 1 deletion server/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sync/atomic"
"time"

"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/ast"
uuidpkg "github.com/google/uuid"
sqlite "github.com/mattn/go-sqlite3"
"google.golang.org/grpc/codes"
Expand Down
12 changes: 6 additions & 6 deletions server/database_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"testing"
"time"

"github.com/cloudspannerecosystem/memefish/pkg/parser"
"github.com/cloudspannerecosystem/memefish/pkg/token"
"github.com/cloudspannerecosystem/memefish"
"github.com/cloudspannerecosystem/memefish/token"
cmp "github.com/google/go-cmp/cmp"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -3439,8 +3439,8 @@ func TestQuery(t *testing.T) {
tc := tc
ses := newSession(db, "foo")
testRunInTransaction(t, ses, func(tx *transaction) {
stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: tc.sql},
},
}).ParseQuery()
Expand Down Expand Up @@ -3564,8 +3564,8 @@ func TestQuery_ArbitraryAssertion(t *testing.T) {
tc := tc
ses := newSession(db, "foo")
testRunInTransaction(t, ses, func(tx *transaction) {
stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: tc.sql},
},
}).ParseQuery()
Expand Down
18 changes: 9 additions & 9 deletions server/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"testing"
"time"

"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/pkg/parser"
"github.com/cloudspannerecosystem/memefish/pkg/token"
"github.com/cloudspannerecosystem/memefish"
"github.com/cloudspannerecosystem/memefish/ast"
"github.com/cloudspannerecosystem/memefish/token"
cmp "github.com/google/go-cmp/cmp"
"google.golang.org/genproto/googleapis/rpc/errdetails"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -578,8 +578,8 @@ func parseDDL(t *testing.T, s string) []ast.DDL {
if stmt == "" {
continue
}
ddl, err := (&parser.Parser{
Lexer: &parser.Lexer{
ddl, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: stmt},
},
}).ParseDDL()
Expand Down Expand Up @@ -3239,8 +3239,8 @@ func TestExecute(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: tt.sql},
},
}).ParseDML()
Expand Down Expand Up @@ -4182,8 +4182,8 @@ func TestInformationSchema(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
ses := newSession(db, "foo")
testRunInTransaction(t, ses, func(tx *transaction) {
stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: tc.sql},
},
}).ParseQuery()
Expand Down
2 changes: 1 addition & 1 deletion server/meta_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package server

import (
"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/ast"
)

var metaTablesMap = map[string]string{
Expand Down
22 changes: 18 additions & 4 deletions server/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"time"

"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/ast"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -1734,12 +1734,26 @@ func (b *QueryBuilder) buildExpr(expr ast.Expr) (Expr, error) {
var args []interface{}
var ss []string
var vts []ValueType
for i := range e.Args {
ex, err := b.buildExpr(e.Args[i].Expr)
for _, arg := range e.Args {
var expr ast.Expr
switch arg := arg.(type) {
case *ast.ExprArg:
expr = arg.Expr
case *ast.IntervalArg:
msg := `Unsupported query shape: IntervalArg in function call is not supported yet.`
return NullExpr, newExprUnimplementedErrorf(expr, msg)
case *ast.SequenceArg:
msg := `Unsupported query shape: SequenceArg in function call is not supported yet.`
return NullExpr, newExprUnimplementedErrorf(expr, msg)
default:
msg := `Invalid query shape: unknown argument type was detected.`
return NullExpr, newExprErrorf(expr, true, msg)
}

ex, err := b.buildExpr(expr)
if err != nil {
return NullExpr, wrapExprError(err, expr, "Args")
}

args = append(args, ex.Args...)
ss = append(ss, ex.Raw)
vts = append(vts, ex.ValueType)
Expand Down
26 changes: 13 additions & 13 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
lropb "cloud.google.com/go/longrunning/autogen/longrunningpb"
adminv1pb "cloud.google.com/go/spanner/admin/database/apiv1/databasepb"
spannerpb "cloud.google.com/go/spanner/apiv1/spannerpb"
"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/pkg/parser"
"github.com/cloudspannerecosystem/memefish/pkg/token"
"github.com/cloudspannerecosystem/memefish"
"github.com/cloudspannerecosystem/memefish/ast"
"github.com/cloudspannerecosystem/memefish/token"
rpcstatus "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -74,8 +74,8 @@ func (s *server) ApplyDDL(ctx context.Context, databaseName string, stmt ast.DDL

// CreateDatabase implements adminv1pb.DatabaseAdminServer.
func (s *server) CreateDatabase(ctx context.Context, req *adminv1pb.CreateDatabaseRequest) (*lropb.Operation, error) {
ddl, err := (&parser.Parser{
Lexer: &parser.Lexer{
ddl, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: req.GetCreateStatement()},
},
}).ParseDDL()
Expand All @@ -89,8 +89,8 @@ func (s *server) CreateDatabase(ctx context.Context, req *adminv1pb.CreateDataba

var stmts []ast.DDL
for _, s := range req.GetExtraStatements() {
stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: s},
},
}).ParseDDL()
Expand Down Expand Up @@ -162,8 +162,8 @@ func (s *server) ListDatabases(ctx context.Context, req *adminv1pb.ListDatabases
func (s *server) UpdateDatabaseDdl(ctx context.Context, req *adminv1pb.UpdateDatabaseDdlRequest) (*lropb.Operation, error) {
var stmts []ast.DDL
for _, s := range req.Statements {
stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: s},
},
}).ParseDDL()
Expand Down Expand Up @@ -607,8 +607,8 @@ func (s *server) ExecuteStreamingSql(req *spannerpb.ExecuteSqlRequest, stream sp
return status.Error(codes.InvalidArgument, "Invalid ExecuteStreamingSql request.")
}

stmt, err := (&parser.Parser{
Lexer: &parser.Lexer{
stmt, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: req.Sql},
},
}).ParseQuery()
Expand Down Expand Up @@ -738,8 +738,8 @@ func (s *server) ExecuteBatchDml(ctx context.Context, req *spannerpb.ExecuteBatc
}

func (s *server) executeDML(ctx context.Context, session *session, tx *transaction, stmt *spannerpb.ExecuteBatchDmlRequest_Statement) (*spannerpb.ResultSet, error) {
dml, err := (&parser.Parser{
Lexer: &parser.Lexer{
dml, err := (&memefish.Parser{
Lexer: &memefish.Lexer{
File: &token.File{FilePath: "", Buffer: stmt.Sql},
},
}).ParseDML()
Expand Down
2 changes: 1 addition & 1 deletion server/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"strconv"

"github.com/cloudspannerecosystem/memefish/pkg/ast"
"github.com/cloudspannerecosystem/memefish/ast"
)

type Table struct {
Expand Down
3 changes: 2 additions & 1 deletion server/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"time"

"database/sql"
"github.com/cloudspannerecosystem/memefish/pkg/ast"

"github.com/cloudspannerecosystem/memefish/ast"
cmp "github.com/google/go-cmp/cmp"
uuidpkg "github.com/google/uuid"
spannerpb "google.golang.org/genproto/googleapis/spanner/v1"
Expand Down

0 comments on commit 3a28861

Please sign in to comment.