(t *testing.T)
| 334 | } |
| 335 | |
| 336 | func TestHashGroupKey(t *testing.T) { |
| 337 | ctx := mock.NewContext() |
| 338 | sc := stmtctx.NewStmtCtxWithTimeZone(time.Local) |
| 339 | eTypes := []types.EvalType{types.ETInt, types.ETReal, types.ETDecimal, types.ETString, types.ETTimestamp, types.ETDatetime, types.ETDuration} |
| 340 | tNames := []string{"int", "real", "decimal", "string", "timestamp", "datetime", "duration"} |
| 341 | for i := 0; i < len(tNames); i++ { |
| 342 | ft := eType2FieldType(eTypes[i]) |
| 343 | if eTypes[i] == types.ETDecimal { |
| 344 | ft.SetFlen(0) |
| 345 | } |
| 346 | colExpr := &Column{Index: 0, RetType: ft} |
| 347 | input := chunk.New([]*types.FieldType{ft}, 1024, 1024) |
| 348 | fillColumnWithGener(eTypes[i], input, 0, nil) |
| 349 | colBuf := chunk.NewColumn(ft, 1024) |
| 350 | bufs := make([][]byte, 1024) |
| 351 | for j := 0; j < 1024; j++ { |
| 352 | bufs[j] = bufs[j][:0] |
| 353 | } |
| 354 | var err error |
| 355 | err = EvalExpr(ctx, ctx.GetSessionVars().EnableVectorizedExpression, colExpr, colExpr.GetType(ctx).EvalType(), input, colBuf) |
| 356 | require.NoError(t, err) |
| 357 | bufs, err = codec.HashGroupKey(sc.TimeZone(), 1024, colBuf, bufs, ft) |
| 358 | require.NoError(t, err) |
| 359 | |
| 360 | var buf []byte |
| 361 | for j := 0; j < input.NumRows(); j++ { |
| 362 | d, err := colExpr.Eval(ctx, input.GetRow(j)) |
| 363 | require.NoError(t, err) |
| 364 | buf, err = codec.EncodeValue(sc.TimeZone(), buf[:0], d) |
| 365 | require.NoError(t, err) |
| 366 | require.Equal(t, string(bufs[j]), string(buf)) |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | func isLogicOrFunction(e Expression) bool { |
| 372 | if f, ok := e.(*ScalarFunction); ok { |
nothing calls this directly
no test coverage detected