-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat(bigquery): improve error when reading null values #6566
feat(bigquery): improve error when reading null values #6566
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
@@ -455,6 +455,10 @@ func runOps(ops []structLoaderOp, vstruct reflect.Value, values []Value) error { | |||
err = setRepeated(field, values[op.valueIndex].([]Value), op.setFunc) | |||
} else { | |||
err = op.setFunc(field, values[op.valueIndex]) | |||
if errors.Is(err, errNoNulls) { | |||
f := vstruct.Type().FieldByIndex(op.fieldIndex) | |||
err = fmt.Errorf("bigquery: NULL cannot be assigned to field `%s` of type %s", f.Name, f.Type.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thing to keep an eye on for the future is whether we should have a custom error type. My suspicion is this isn't a frequent enough failure to warrant custom errors at this point, nor is it super actionable unless you're dynamically rewriting things.
Improve error message when reading NULL values from a query and trying to fit into a struct field.
Resolves #2612