Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Fix ROUND function for 2 args. #580

Merged
merged 2 commits into from
Dec 26, 2018
Merged
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
12 changes: 12 additions & 0 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,18 @@ var queries = []struct {
{int64(123)},
},
},
{
`SELECT round(15728640/1024/1024)`,
[]sql.Row{
{int64(15)},
},
},
{
`SELECT round(15, 1)`,
[]sql.Row{
{int64(15)},
},
},
}

func TestQueries(t *testing.T) {
Expand Down
43 changes: 42 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,55 @@
module gopkg.in/src-d/go-mysql-server.v0

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/CAFxX/gcnotifier v0.0.0-20170518020117-39b0596a2da3 // indirect
github.com/DataDog/datadog-go v0.0.0-20180822151419-281ae9f2d895 // indirect
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/boltdb/bolt v1.3.1
github.com/cespare/xxhash v1.1.0 // indirect
github.com/circonus-labs/circonus-gometrics v2.2.5+incompatible // indirect
github.com/circonus-labs/circonusllhist v0.1.3 // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/go-ole/go-ole v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.4.1
github.com/gogo/protobuf v1.2.0 // indirect
github.com/google/go-cmp v0.2.0 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/handlers v1.4.0 // indirect
github.com/gorilla/mux v1.6.2 // indirect
github.com/hashicorp/consul v1.4.0 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-retryablehttp v0.5.0 // indirect
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
github.com/hashicorp/memberlist v0.1.0 // indirect
github.com/hashicorp/serf v0.8.1 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/miekg/dns v1.1.1 // indirect
github.com/mitchellh/hashstructure v1.0.0
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
github.com/opentracing/opentracing-go v1.0.2
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/pilosa/pilosa v1.2.0
github.com/pkg/errors v0.8.0 // indirect
github.com/prometheus/client_golang v0.9.2 // indirect
github.com/sanity-io/litter v1.1.0
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/shirou/gopsutil v2.18.11+incompatible // indirect
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/sirupsen/logrus v1.1.1
github.com/spf13/cast v1.3.0
golang.org/x/net v0.0.0-20181029044818-c44066c5c816 // indirect
github.com/stretchr/testify v1.2.2
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect
github.com/uber/jaeger-client-go v2.15.0+incompatible // indirect
github.com/uber/jaeger-lib v2.0.0+incompatible // indirect
google.golang.org/grpc v1.16.0 // indirect
gopkg.in/src-d/go-errors.v1 v1.0.0
gopkg.in/src-d/go-vitess.v1 v1.4.0
gopkg.in/vmihailenco/msgpack.v2 v2.9.1 // indirect
gopkg.in/yaml.v2 v2.2.2
)
2 changes: 1 addition & 1 deletion sql/expression/function/ceil_round_floor.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (r *Round) Children() []sql.Expression {
return []sql.Expression{r.Left}
}

return r.Children()
return r.BinaryExpression.Children()
}

// Eval implements the Expression interface.
Expand Down
11 changes: 10 additions & 1 deletion sql/expression/function/ceil_round_floor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func TestCeil(t *testing.T) {

t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
exprs := f.Children()
require.True(len(exprs) > 0 && len(exprs) < 3)
require.NotNil(exprs[0])

result, err := f.Eval(sql.NewEmptyContext(), tt.row)
if tt.err != nil {
Expand Down Expand Up @@ -88,6 +91,9 @@ func TestFloor(t *testing.T) {

t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
exprs := f.Children()
require.True(len(exprs) > 0 && len(exprs) < 3)
require.NotNil(exprs[0])

result, err := f.Eval(sql.NewEmptyContext(), tt.row)
if tt.err != nil {
Expand Down Expand Up @@ -206,9 +212,12 @@ func TestRound(t *testing.T) {

f, err := NewRound(args...)
req := require.New(t)

req.Nil(err)

exprs := f.Children()
req.True(len(exprs) > 0 && len(exprs) < 3)
req.NotNil(exprs[0])

result, err := f.Eval(sql.NewEmptyContext(), sql.NewRow([]byte{1, 2, 3}, 2))

req.Equal(int32(0), result)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy