Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: to fill default value when nullable and default value are both enable #36030

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 18 additions & 28 deletions internal/proxy/validate_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,12 @@
}

case *schemapb.ScalarField_ArrayData:
// Todo: support it
if fieldSchema.GetNullable() {
sd.ArrayData.Data, err = fillWithNullValueImpl(sd.ArrayData.Data, field.GetValidData())
if err != nil {
return err

Check warning on line 359 in internal/proxy/validate_util.go

View check run for this annotation

Codecov / codecov/patch

internal/proxy/validate_util.go#L357-L359

Added lines #L357 - L359 were not covered by tests
}
}

case *schemapb.ScalarField_JsonData:
if fieldSchema.GetNullable() {
Expand Down Expand Up @@ -391,10 +396,6 @@
return err
}

if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

case *schemapb.ScalarField_IntData:
if len(field.GetValidData()) != numRows {
msg := fmt.Sprintf("the length of valid_data of field(%s) is wrong", field.GetFieldName())
Expand All @@ -406,10 +407,6 @@
return err
}

if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

case *schemapb.ScalarField_LongData:
if len(field.GetValidData()) != numRows {
msg := fmt.Sprintf("the length of valid_data of field(%s) is wrong", field.GetFieldName())
Expand All @@ -420,9 +417,6 @@
if err != nil {
return err
}
if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

case *schemapb.ScalarField_FloatData:
if len(field.GetValidData()) != numRows {
Expand All @@ -435,10 +429,6 @@
return err
}

if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

case *schemapb.ScalarField_DoubleData:
if len(field.GetValidData()) != numRows {
msg := fmt.Sprintf("the length of valid_data of field(%s) is wrong", field.GetFieldName())
Expand All @@ -450,10 +440,6 @@
return err
}

if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

case *schemapb.ScalarField_StringData:
if len(field.GetValidData()) != numRows {
msg := fmt.Sprintf("the length of valid_data of field(%s) is wrong", field.GetFieldName())
Expand All @@ -465,10 +451,6 @@
return err
}

if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

case *schemapb.ScalarField_ArrayData:
// Todo: support it
log.Error("array type not support default value", zap.String("fieldSchemaName", field.GetFieldName()))
Expand All @@ -485,10 +467,6 @@
return err
}

if !fieldSchema.GetNullable() {
field.ValidData = []bool{}
}

default:
return merr.WrapErrParameterInvalidMsg(fmt.Sprintf("undefined data type:%s", field.Type.String()))
}
Expand All @@ -501,6 +479,18 @@
return merr.WrapErrParameterInvalidMsg(fmt.Sprintf("undefined data type:%s", field.Type.String()))
}

if !typeutil.IsVectorType(field.Type) {
if fieldSchema.GetNullable() {
validData := make([]bool, numRows)
for i := range validData {
validData[i] = true
}
field.ValidData = validData
} else {
field.ValidData = []bool{}
}
}

err = checkValidData(field, fieldSchema, numRows)
if err != nil {
return err
Expand Down
Loading
Loading