Enable print_log support json data type (#26118)

Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>
pull/26130/head
zhenshan.cao 2023-08-04 11:27:05 +08:00 committed by GitHub
parent 6f89620a43
commit 2c6c7749e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -321,6 +321,19 @@ func printPayloadValues(colType schemapb.DataType, reader PayloadReaderInterface
}
fmt.Println()
}
case schemapb.DataType_JSON:
rows, err := reader.GetPayloadLengthFromReader()
if err != nil {
return err
}
val, err := reader.GetJSONFromPayload()
if err != nil {
return err
}
for i := 0; i < rows; i++ {
fmt.Printf("\t\t%d : %s\n", i, val[i])
}
default:
return errors.New("undefined data type")
}

View File

@ -179,6 +179,13 @@ func TestPrintBinlogFiles(t *testing.T) {
Description: "description_11",
DataType: schemapb.DataType_FloatVector,
},
{
FieldID: 110,
Name: "field_json",
IsPrimaryKey: false,
Description: "description_12",
DataType: schemapb.DataType_JSON,
},
},
},
}
@ -223,6 +230,12 @@ func TestPrintBinlogFiles(t *testing.T) {
Data: []float32{0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7},
Dim: 8,
},
110: &JSONFieldData{
Data: [][]byte{
[]byte(`{}`),
[]byte(`{"key":"hello"}`),
},
},
},
}
@ -266,6 +279,12 @@ func TestPrintBinlogFiles(t *testing.T) {
Data: []float32{0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7},
Dim: 8,
},
110: &JSONFieldData{
Data: [][]byte{
[]byte(`{}`),
[]byte(`{"key":"world"}`),
},
},
},
}
firstBlobs, err := insertCodec.Serialize(1, 1, insertDataFirst)