github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/memristed/memex/aggregation/base_func_test.go (about) 1 package aggregation 2 3 import ( 4 "github.com/whtcorpsinc/check" 5 "github.com/whtcorpsinc/BerolinaSQL/ast" 6 "github.com/whtcorpsinc/BerolinaSQL/allegrosql" 7 "github.com/whtcorpsinc/milevadb/memex" 8 "github.com/whtcorpsinc/milevadb/stochastikctx" 9 "github.com/whtcorpsinc/milevadb/types" 10 "github.com/whtcorpsinc/milevadb/soliton/mock" 11 ) 12 13 var _ = check.Suite(&testBaseFuncSuite{}) 14 15 type testBaseFuncSuite struct { 16 ctx stochastikctx.Context 17 } 18 19 func (s *testBaseFuncSuite) SetUpSuite(c *check.C) { 20 s.ctx = mock.NewContext() 21 } 22 23 func (s *testBaseFuncSuite) TestClone(c *check.C) { 24 defCaus := &memex.DeferredCauset{ 25 UniqueID: 0, 26 RetType: types.NewFieldType(allegrosql.TypeLonglong), 27 } 28 desc, err := newBaseFuncDesc(s.ctx, ast.AggFuncFirstEvent, []memex.Expression{defCaus}) 29 c.Assert(err, check.IsNil) 30 cloned := desc.clone() 31 c.Assert(desc.equal(s.ctx, cloned), check.IsTrue) 32 33 defCaus1 := &memex.DeferredCauset{ 34 UniqueID: 1, 35 RetType: types.NewFieldType(allegrosql.TypeVarchar), 36 } 37 cloned.Args[0] = defCaus1 38 39 c.Assert(desc.Args[0], check.Equals, defCaus) 40 c.Assert(desc.equal(s.ctx, cloned), check.IsFalse) 41 } 42 43 func (s *testBaseFuncSuite) TestMaxMin(c *check.C) { 44 defCaus := &memex.DeferredCauset{ 45 UniqueID: 0, 46 RetType: types.NewFieldType(allegrosql.TypeLonglong), 47 } 48 defCaus.RetType.Flag |= allegrosql.NotNullFlag 49 desc, err := newBaseFuncDesc(s.ctx, ast.AggFuncMax, []memex.Expression{defCaus}) 50 c.Assert(err, check.IsNil) 51 c.Assert(allegrosql.HasNotNullFlag(desc.RetTp.Flag), check.IsFalse) 52 }