diff --git a/pkg/vm/engine/tae/common/print.go b/pkg/vm/engine/tae/common/print.go index 003cf2b563074..0a16e91b26a69 100644 --- a/pkg/vm/engine/tae/common/print.go +++ b/pkg/vm/engine/tae/common/print.go @@ -259,7 +259,18 @@ func MoVectorToString(v *vector.Vector, printN int, opts ...TypePrintOpt) string return vec2Str(vector.MustFixedColWithTypeCheck[types.Blockid](v)[:printN], v) } if v.GetType().IsVarlen() { - return vec2Str(vector.InefficientMustBytesCol(v)[:printN], v, opts...) + if !v.HasNull() { + return vec2Str(vector.InefficientMustBytesCol(v)[:printN], v, opts...) + } + vs := make([][]byte, 0, printN) + for i := 0; i < printN; i++ { + if v.GetNulls().Contains(uint64(i)) { + vs = append(vs, nil) + } else { + vs = append(vs, v.GetBytesAt(i)) + } + } + return vec2Str(vs, v, opts...) } return fmt.Sprintf("unkown type vec... %v", *v.GetType()) } diff --git a/pkg/vm/engine/tae/db/test/db_test.go b/pkg/vm/engine/tae/db/test/db_test.go index d38f179a3a474..31b0e63b87213 100644 --- a/pkg/vm/engine/tae/db/test/db_test.go +++ b/pkg/vm/engine/tae/db/test/db_test.go @@ -19,6 +19,7 @@ import ( "context" "errors" "fmt" + "math" "math/rand" "reflect" "sort" @@ -81,6 +82,26 @@ const ( defaultGlobalCheckpointTimeout = 10 * time.Second ) +func TestPrintVector(t *testing.T) { + defer testutils.AfterTest(t)() + testutils.EnsureNoLeak(t) + + mp, err := mpool.NewMPool("test", 0, mpool.NoFixed) + assert.NoError(t, err) + vec1 := vector.NewVec(types.T_uint32.ToType()) + defer vec1.Free(mp) + for i := 0; i < 10; i++ { + err = vector.AppendFixed[uint32](vec1, math.MaxUint32, false, mp) + assert.NoError(t, err) + } + + vec1.Reset(types.T_varchar.ToType()) + err = vector.AppendBytes(vec1, nil, true, mp) + require.NoError(t, err) + s := common.MoVectorToString(vec1, 10) + t.Log(s) +} + func TestAppend1(t *testing.T) { defer testutils.AfterTest(t)() testutils.EnsureNoLeak(t)