github.com/matrixorigin/matrixone@v0.7.0/pkg/sql/util/index_util.go (about)

     1  // Copyright 2021 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package util
    16  
    17  import (
    18  	"context"
    19  
    20  	"github.com/google/uuid"
    21  	"github.com/matrixorigin/matrixone/pkg/catalog"
    22  	"github.com/matrixorigin/matrixone/pkg/common/moerr"
    23  	"github.com/matrixorigin/matrixone/pkg/container/batch"
    24  	"github.com/matrixorigin/matrixone/pkg/container/nulls"
    25  	"github.com/matrixorigin/matrixone/pkg/container/types"
    26  	"github.com/matrixorigin/matrixone/pkg/container/vector"
    27  	"github.com/matrixorigin/matrixone/pkg/vm/process"
    28  )
    29  
    30  var SerialWithCompacted = serialWithCompacted
    31  var CompactSingleIndexCol = compactSingleIndexCol
    32  var CompactPrimaryCol = compactPrimaryCol
    33  
    34  func BuildIndexTableName(ctx context.Context, unique bool) (string, error) {
    35  	var name string
    36  	name = catalog.PrefixIndexTableName
    37  	if unique {
    38  		name += "unique_"
    39  	} else {
    40  		name += "secondary_"
    41  	}
    42  	id, err := uuid.NewUUID()
    43  	if err != nil {
    44  		return "", moerr.NewInternalError(ctx, "newuuid failed")
    45  	}
    46  	name += id.String()
    47  	return name, nil
    48  }
    49  
    50  func BuildUniqueKeyBatch(vecs []*vector.Vector, attrs []string, parts []string, originTablePrimaryKey string, proc *process.Process) (*batch.Batch, int) {
    51  	var b *batch.Batch
    52  	if originTablePrimaryKey == "" {
    53  		b = &batch.Batch{
    54  			Attrs: make([]string, 1),
    55  			Vecs:  make([]*vector.Vector, 1),
    56  			Cnt:   1,
    57  		}
    58  		b.Attrs[0] = catalog.IndexTableIndexColName
    59  	} else {
    60  		b = &batch.Batch{
    61  			Attrs: make([]string, 2),
    62  			Vecs:  make([]*vector.Vector, 2),
    63  			Cnt:   1,
    64  		}
    65  		b.Attrs[0] = catalog.IndexTableIndexColName
    66  		b.Attrs[1] = catalog.IndexTablePrimaryColName
    67  	}
    68  	isCompoundIndex := false
    69  	if len(parts) > 1 {
    70  		isCompoundIndex = true
    71  	}
    72  	//bitMap := new(nulls.Nulls)
    73  	var bitMap *nulls.Nulls
    74  	if isCompoundIndex {
    75  		cIndexVecMap := make(map[string]*vector.Vector)
    76  		for num, attrName := range attrs {
    77  			for _, name := range parts {
    78  				if attrName == name {
    79  					cIndexVecMap[name] = vecs[num]
    80  				}
    81  			}
    82  		}
    83  		vs := make([]*vector.Vector, 0)
    84  		for _, part := range parts {
    85  			v := cIndexVecMap[part]
    86  			vs = append(vs, v)
    87  		}
    88  		b.Vecs[0], bitMap = serialWithCompacted(vs, proc)
    89  	} else {
    90  		var vec *vector.Vector
    91  		for i, name := range attrs {
    92  			if parts[0] == name {
    93  				vec = vecs[i]
    94  				break
    95  			}
    96  		}
    97  		b.Vecs[0], bitMap = compactSingleIndexCol(vec, proc)
    98  	}
    99  
   100  	if len(b.Attrs) > 1 {
   101  		var vec *vector.Vector
   102  		for i, name := range attrs {
   103  			if originTablePrimaryKey == name {
   104  				vec = vecs[i]
   105  			}
   106  		}
   107  		b.Vecs[1] = compactPrimaryCol(vec, bitMap, proc)
   108  	}
   109  
   110  	b.SetZs(vector.Length(b.Vecs[0]), proc.Mp())
   111  	return b, vector.Length(b.Vecs[0])
   112  }
   113  
   114  // SerialWithCompacted have a similar function named Serial
   115  // SerialWithCompacted function is used by BuildUniqueKeyBatch
   116  // when vs have null value, the function will ignore the row in
   117  // the vs
   118  // for example:
   119  // input vec is [[1, 1, 1], [2, 2, null], [3, 3, 3]]
   120  // result vec is [serial(1, 2, 3), serial(1, 2, 3)]
   121  // result bitmap is [2]
   122  func serialWithCompacted(vs []*vector.Vector, proc *process.Process) (*vector.Vector, *nulls.Nulls) {
   123  	// resolve vs
   124  	length := vector.Length(vs[0])
   125  	vct := types.T_varchar.ToType()
   126  	nsp := new(nulls.Nulls)
   127  	val := make([][]byte, 0, length)
   128  	ps := types.NewPackerArray(length, proc.Mp())
   129  	bitMap := new(nulls.Nulls)
   130  
   131  	for _, v := range vs {
   132  		switch v.Typ.Oid {
   133  		case types.T_bool:
   134  			s := vector.MustTCols[bool](v)
   135  			for i, b := range s {
   136  				if nulls.Contains(v.Nsp, uint64(i)) {
   137  					nulls.Add(bitMap, uint64(i))
   138  				} else {
   139  					ps[i].EncodeBool(b)
   140  				}
   141  			}
   142  		case types.T_int8:
   143  			s := vector.MustTCols[int8](v)
   144  			for i, b := range s {
   145  				if nulls.Contains(v.Nsp, uint64(i)) {
   146  					nulls.Add(bitMap, uint64(i))
   147  				} else {
   148  					ps[i].EncodeInt8(b)
   149  				}
   150  			}
   151  		case types.T_int16:
   152  			s := vector.MustTCols[int16](v)
   153  			for i, b := range s {
   154  				if nulls.Contains(v.Nsp, uint64(i)) {
   155  					nulls.Add(bitMap, uint64(i))
   156  				} else {
   157  					ps[i].EncodeInt16(b)
   158  				}
   159  			}
   160  		case types.T_int32:
   161  			s := vector.MustTCols[int32](v)
   162  			for i, b := range s {
   163  				if nulls.Contains(v.Nsp, uint64(i)) {
   164  					nulls.Add(bitMap, uint64(i))
   165  				} else {
   166  					ps[i].EncodeInt32(b)
   167  				}
   168  			}
   169  		case types.T_int64:
   170  			s := vector.MustTCols[int64](v)
   171  			for i, b := range s {
   172  				if nulls.Contains(v.Nsp, uint64(i)) {
   173  					nulls.Add(bitMap, uint64(i))
   174  				} else {
   175  					ps[i].EncodeInt64(b)
   176  				}
   177  			}
   178  		case types.T_uint8:
   179  			s := vector.MustTCols[uint8](v)
   180  			for i, b := range s {
   181  				if nulls.Contains(v.Nsp, uint64(i)) {
   182  					nulls.Add(bitMap, uint64(i))
   183  				} else {
   184  					ps[i].EncodeUint8(b)
   185  				}
   186  			}
   187  		case types.T_uint16:
   188  			s := vector.MustTCols[uint16](v)
   189  			for i, b := range s {
   190  				if nulls.Contains(v.Nsp, uint64(i)) {
   191  					nulls.Add(bitMap, uint64(i))
   192  				} else {
   193  					ps[i].EncodeUint16(b)
   194  				}
   195  			}
   196  		case types.T_uint32:
   197  			s := vector.MustTCols[uint32](v)
   198  			for i, b := range s {
   199  				if nulls.Contains(v.Nsp, uint64(i)) {
   200  					nulls.Add(bitMap, uint64(i))
   201  				} else {
   202  					ps[i].EncodeUint32(b)
   203  				}
   204  			}
   205  		case types.T_uint64:
   206  			s := vector.MustTCols[uint64](v)
   207  			for i, b := range s {
   208  				if nulls.Contains(v.Nsp, uint64(i)) {
   209  					nulls.Add(bitMap, uint64(i))
   210  				} else {
   211  					ps[i].EncodeUint64(b)
   212  				}
   213  			}
   214  		case types.T_float32:
   215  			s := vector.MustTCols[float32](v)
   216  			for i, b := range s {
   217  				if nulls.Contains(v.Nsp, uint64(i)) {
   218  					nulls.Add(bitMap, uint64(i))
   219  				} else {
   220  					ps[i].EncodeFloat32(b)
   221  				}
   222  			}
   223  		case types.T_float64:
   224  			s := vector.MustTCols[float64](v)
   225  			for i, b := range s {
   226  				if nulls.Contains(v.Nsp, uint64(i)) {
   227  					nulls.Add(bitMap, uint64(i))
   228  				} else {
   229  					ps[i].EncodeFloat64(b)
   230  				}
   231  			}
   232  		case types.T_date:
   233  			s := vector.MustTCols[types.Date](v)
   234  			for i, b := range s {
   235  				if nulls.Contains(v.Nsp, uint64(i)) {
   236  					nulls.Add(bitMap, uint64(i))
   237  				} else {
   238  					ps[i].EncodeDate(b)
   239  				}
   240  			}
   241  		case types.T_time:
   242  			s := vector.MustTCols[types.Time](v)
   243  			for i, b := range s {
   244  				if nulls.Contains(v.Nsp, uint64(i)) {
   245  					nulls.Add(bitMap, uint64(i))
   246  				} else {
   247  					ps[i].EncodeTime(b)
   248  				}
   249  			}
   250  		case types.T_datetime:
   251  			s := vector.MustTCols[types.Datetime](v)
   252  			for i, b := range s {
   253  				if nulls.Contains(v.Nsp, uint64(i)) {
   254  					nulls.Add(bitMap, uint64(i))
   255  				} else {
   256  					ps[i].EncodeDatetime(b)
   257  				}
   258  			}
   259  		case types.T_timestamp:
   260  			s := vector.MustTCols[types.Timestamp](v)
   261  			for i, b := range s {
   262  				if nulls.Contains(v.Nsp, uint64(i)) {
   263  					nulls.Add(bitMap, uint64(i))
   264  				} else {
   265  					ps[i].EncodeTimestamp(b)
   266  				}
   267  			}
   268  		case types.T_decimal64:
   269  			s := vector.MustTCols[types.Decimal64](v)
   270  			for i, b := range s {
   271  				if nulls.Contains(v.Nsp, uint64(i)) {
   272  					nulls.Add(bitMap, uint64(i))
   273  				} else {
   274  					ps[i].EncodeDecimal64(b)
   275  				}
   276  			}
   277  		case types.T_decimal128:
   278  			s := vector.MustTCols[types.Decimal128](v)
   279  			for i, b := range s {
   280  				if nulls.Contains(v.Nsp, uint64(i)) {
   281  					nulls.Add(bitMap, uint64(i))
   282  				} else {
   283  					ps[i].EncodeDecimal128(b)
   284  				}
   285  			}
   286  		case types.T_json, types.T_char, types.T_varchar, types.T_blob, types.T_text:
   287  			vs := vector.GetStrVectorValues(v)
   288  			for i := range vs {
   289  				if nulls.Contains(v.Nsp, uint64(i)) {
   290  					nulls.Add(bitMap, uint64(i))
   291  				} else {
   292  					ps[i].EncodeStringType([]byte(vs[i]))
   293  				}
   294  			}
   295  		}
   296  	}
   297  
   298  	for i := range ps {
   299  		if !nulls.Contains(bitMap, uint64(i)) {
   300  			val = append(val, ps[i].GetBuf())
   301  		}
   302  	}
   303  
   304  	vec := vector.NewWithBytes(vct, val, nsp, proc.Mp())
   305  
   306  	return vec, bitMap
   307  }
   308  
   309  func compactSingleIndexCol(v *vector.Vector, proc *process.Process) (*vector.Vector, *nulls.Nulls) {
   310  	nsp := new(nulls.Nulls)
   311  	var vec *vector.Vector
   312  	length := vector.Length(v)
   313  	switch v.Typ.Oid {
   314  	case types.T_bool:
   315  		s := vector.MustTCols[bool](v)
   316  		ns := make([]bool, 0, length)
   317  		for i, b := range s {
   318  			if !nulls.Contains(v.Nsp, uint64(i)) {
   319  				ns = append(ns, b)
   320  			}
   321  		}
   322  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   323  	case types.T_int8:
   324  		s := vector.MustTCols[int8](v)
   325  		ns := make([]int8, 0, len(s)-nulls.Size(nsp))
   326  		for i, b := range s {
   327  			if !nulls.Contains(v.Nsp, uint64(i)) {
   328  				ns = append(ns, b)
   329  			}
   330  		}
   331  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   332  	case types.T_int16:
   333  		s := vector.MustTCols[int16](v)
   334  		ns := make([]int16, 0, len(s)-nulls.Size(nsp))
   335  		for i, b := range s {
   336  			if !nulls.Contains(v.Nsp, uint64(i)) {
   337  				ns = append(ns, b)
   338  			}
   339  		}
   340  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   341  	case types.T_int32:
   342  		s := vector.MustTCols[int32](v)
   343  		ns := make([]int32, 0, len(s)-nulls.Size(nsp))
   344  		for i, b := range s {
   345  			if !nulls.Contains(v.Nsp, uint64(i)) {
   346  				ns = append(ns, b)
   347  			}
   348  		}
   349  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   350  	case types.T_int64:
   351  		s := vector.MustTCols[int64](v)
   352  		ns := make([]int64, 0, len(s)-nulls.Size(nsp))
   353  		for i, b := range s {
   354  			if !nulls.Contains(v.Nsp, uint64(i)) {
   355  				ns = append(ns, b)
   356  			}
   357  		}
   358  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   359  	case types.T_uint8:
   360  		s := vector.MustTCols[uint8](v)
   361  		ns := make([]uint8, 0, len(s)-nulls.Size(nsp))
   362  		for i, b := range s {
   363  			if !nulls.Contains(v.Nsp, uint64(i)) {
   364  				ns = append(ns, b)
   365  			}
   366  		}
   367  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   368  	case types.T_uint16:
   369  		s := vector.MustTCols[uint16](v)
   370  		ns := make([]uint16, 0, len(s)-nulls.Size(nsp))
   371  		for i, b := range s {
   372  			if !nulls.Contains(v.Nsp, uint64(i)) {
   373  				ns = append(ns, b)
   374  			}
   375  		}
   376  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   377  	case types.T_uint32:
   378  		s := vector.MustTCols[uint32](v)
   379  		ns := make([]uint32, 0, len(s)-nulls.Size(nsp))
   380  		for i, b := range s {
   381  			if !nulls.Contains(v.Nsp, uint64(i)) {
   382  				ns = append(ns, b)
   383  			}
   384  		}
   385  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   386  	case types.T_uint64:
   387  		s := vector.MustTCols[uint64](v)
   388  		ns := make([]uint64, 0, len(s)-nulls.Size(nsp))
   389  		for i, b := range s {
   390  			if !nulls.Contains(v.Nsp, uint64(i)) {
   391  				ns = append(ns, b)
   392  			}
   393  		}
   394  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   395  	case types.T_float32:
   396  		s := vector.MustTCols[float32](v)
   397  		ns := make([]float32, 0, len(s)-nulls.Size(nsp))
   398  		for i, b := range s {
   399  			if !nulls.Contains(v.Nsp, uint64(i)) {
   400  				ns = append(ns, b)
   401  			}
   402  		}
   403  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   404  	case types.T_float64:
   405  		s := vector.MustTCols[float64](v)
   406  		ns := make([]float64, 0, len(s)-nulls.Size(nsp))
   407  		for i, b := range s {
   408  			if !nulls.Contains(v.Nsp, uint64(i)) {
   409  				ns = append(ns, b)
   410  			}
   411  		}
   412  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   413  	case types.T_date:
   414  		s := vector.MustTCols[types.Date](v)
   415  		ns := make([]types.Date, 0, len(s)-nulls.Size(nsp))
   416  		for i, b := range s {
   417  			if !nulls.Contains(v.Nsp, uint64(i)) {
   418  				ns = append(ns, b)
   419  			}
   420  		}
   421  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   422  	case types.T_time:
   423  		s := vector.MustTCols[types.Time](v)
   424  		ns := make([]types.Time, 0, len(s)-nulls.Size(nsp))
   425  		for i, b := range s {
   426  			if !nulls.Contains(v.Nsp, uint64(i)) {
   427  				ns = append(ns, b)
   428  			}
   429  		}
   430  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   431  	case types.T_datetime:
   432  		s := vector.MustTCols[types.Datetime](v)
   433  		ns := make([]types.Datetime, 0, len(s)-nulls.Size(nsp))
   434  		for i, b := range s {
   435  			if !nulls.Contains(v.Nsp, uint64(i)) {
   436  				ns = append(ns, b)
   437  			}
   438  		}
   439  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   440  	case types.T_timestamp:
   441  		s := vector.MustTCols[types.Timestamp](v)
   442  		ns := make([]types.Timestamp, 0, len(s)-nulls.Size(nsp))
   443  		for i, b := range s {
   444  			if !nulls.Contains(v.Nsp, uint64(i)) {
   445  				ns = append(ns, b)
   446  			}
   447  		}
   448  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   449  	case types.T_decimal64:
   450  		s := vector.MustTCols[types.Decimal64](v)
   451  		ns := make([]types.Decimal64, 0, len(s)-nulls.Size(nsp))
   452  		for i, b := range s {
   453  			if !nulls.Contains(v.Nsp, uint64(i)) {
   454  				ns = append(ns, b)
   455  			}
   456  		}
   457  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   458  	case types.T_decimal128:
   459  		s := vector.MustTCols[types.Decimal128](v)
   460  		ns := make([]types.Decimal128, 0, len(s)-nulls.Size(nsp))
   461  		for i, b := range s {
   462  			if !nulls.Contains(v.Nsp, uint64(i)) {
   463  				ns = append(ns, b)
   464  			}
   465  		}
   466  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   467  	case types.T_json, types.T_char, types.T_varchar, types.T_blob:
   468  		s := vector.GetStrVectorValues(v)
   469  		ns := make([]string, 0, len(s)-nulls.Size(nsp))
   470  		for i, b := range s {
   471  			if !nulls.Contains(v.Nsp, uint64(i)) {
   472  				ns = append(ns, b)
   473  			}
   474  		}
   475  		vec = vector.NewWithStrings(v.Typ, ns, nsp, proc.Mp())
   476  	}
   477  	return vec, v.Nsp
   478  }
   479  func compactPrimaryCol(v *vector.Vector, bitMap *nulls.Nulls, proc *process.Process) *vector.Vector {
   480  	nsp := new(nulls.Nulls)
   481  	var vec *vector.Vector
   482  	length := vector.Length(v)
   483  	switch v.Typ.Oid {
   484  	case types.T_bool:
   485  		s := vector.MustTCols[bool](v)
   486  		ns := make([]bool, 0, length)
   487  		for i, b := range s {
   488  			if !nulls.Contains(bitMap, uint64(i)) {
   489  				ns = append(ns, b)
   490  			}
   491  		}
   492  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   493  	case types.T_int8:
   494  		s := vector.MustTCols[int8](v)
   495  		ns := make([]int8, 0)
   496  		for i, b := range s {
   497  			if !nulls.Contains(bitMap, uint64(i)) {
   498  				ns = append(ns, b)
   499  			}
   500  		}
   501  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   502  	case types.T_int16:
   503  		s := vector.MustTCols[int16](v)
   504  		ns := make([]int16, 0)
   505  		for i, b := range s {
   506  			if !nulls.Contains(bitMap, uint64(i)) {
   507  				ns = append(ns, b)
   508  			}
   509  		}
   510  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   511  	case types.T_int32:
   512  		s := vector.MustTCols[int32](v)
   513  		ns := make([]int32, 0)
   514  		for i, b := range s {
   515  			if !nulls.Contains(bitMap, uint64(i)) {
   516  				ns = append(ns, b)
   517  			}
   518  		}
   519  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   520  	case types.T_int64:
   521  		s := vector.MustTCols[int64](v)
   522  		ns := make([]int64, 0)
   523  		for i, b := range s {
   524  			if !nulls.Contains(bitMap, uint64(i)) {
   525  				ns = append(ns, b)
   526  			}
   527  		}
   528  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   529  	case types.T_uint8:
   530  		s := vector.MustTCols[uint8](v)
   531  		ns := make([]uint8, 0)
   532  		for i, b := range s {
   533  			if !nulls.Contains(bitMap, uint64(i)) {
   534  				ns = append(ns, b)
   535  			}
   536  		}
   537  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   538  	case types.T_uint16:
   539  		s := vector.MustTCols[uint16](v)
   540  		ns := make([]uint16, 0)
   541  		for i, b := range s {
   542  			if !nulls.Contains(bitMap, uint64(i)) {
   543  				ns = append(ns, b)
   544  			}
   545  		}
   546  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   547  	case types.T_uint32:
   548  		s := vector.MustTCols[uint32](v)
   549  		ns := make([]uint32, 0)
   550  		for i, b := range s {
   551  			if !nulls.Contains(bitMap, uint64(i)) {
   552  				ns = append(ns, b)
   553  			}
   554  		}
   555  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   556  	case types.T_uint64:
   557  		s := vector.MustTCols[uint64](v)
   558  		ns := make([]uint64, 0)
   559  		for i, b := range s {
   560  			if !nulls.Contains(bitMap, uint64(i)) {
   561  				ns = append(ns, b)
   562  			}
   563  		}
   564  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   565  	case types.T_float32:
   566  		s := vector.MustTCols[float32](v)
   567  		ns := make([]float32, 0)
   568  		for i, b := range s {
   569  			if !nulls.Contains(bitMap, uint64(i)) {
   570  				ns = append(ns, b)
   571  			}
   572  		}
   573  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   574  	case types.T_float64:
   575  		s := vector.MustTCols[float64](v)
   576  		ns := make([]float64, 0)
   577  		for i, b := range s {
   578  			if !nulls.Contains(bitMap, uint64(i)) {
   579  				ns = append(ns, b)
   580  			}
   581  		}
   582  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   583  	case types.T_date:
   584  		s := vector.MustTCols[types.Date](v)
   585  		ns := make([]types.Date, 0)
   586  		for i, b := range s {
   587  			if !nulls.Contains(bitMap, uint64(i)) {
   588  				ns = append(ns, b)
   589  			}
   590  		}
   591  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   592  	case types.T_time:
   593  		s := vector.MustTCols[types.Time](v)
   594  		ns := make([]types.Time, 0)
   595  		for i, b := range s {
   596  			if !nulls.Contains(bitMap, uint64(i)) {
   597  				ns = append(ns, b)
   598  			}
   599  		}
   600  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   601  	case types.T_datetime:
   602  		s := vector.MustTCols[types.Datetime](v)
   603  		ns := make([]types.Datetime, 0)
   604  		for i, b := range s {
   605  			if !nulls.Contains(bitMap, uint64(i)) {
   606  				ns = append(ns, b)
   607  			}
   608  		}
   609  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   610  	case types.T_timestamp:
   611  		s := vector.MustTCols[types.Timestamp](v)
   612  		ns := make([]types.Timestamp, 0)
   613  		for i, b := range s {
   614  			if !nulls.Contains(bitMap, uint64(i)) {
   615  				ns = append(ns, b)
   616  			}
   617  		}
   618  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   619  	case types.T_decimal64:
   620  		s := vector.MustTCols[types.Decimal64](v)
   621  		ns := make([]types.Decimal64, 0)
   622  		for i, b := range s {
   623  			if !nulls.Contains(bitMap, uint64(i)) {
   624  				ns = append(ns, b)
   625  			}
   626  		}
   627  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   628  	case types.T_decimal128:
   629  		s := vector.MustTCols[types.Decimal128](v)
   630  		ns := make([]types.Decimal128, 0)
   631  		for i, b := range s {
   632  			if !nulls.Contains(bitMap, uint64(i)) {
   633  				ns = append(ns, b)
   634  			}
   635  		}
   636  		vec = vector.NewWithFixed(v.Typ, ns, nsp, proc.Mp())
   637  	case types.T_json, types.T_char, types.T_varchar, types.T_blob:
   638  		s := vector.GetStrVectorValues(v)
   639  		ns := make([]string, 0)
   640  		for i, b := range s {
   641  			if !nulls.Contains(bitMap, uint64(i)) {
   642  				ns = append(ns, b)
   643  			}
   644  		}
   645  		vec = vector.NewWithStrings(v.Typ, ns, nsp, proc.Mp())
   646  	}
   647  	return vec
   648  }