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

MapKey: print more concise error messages when check whether two map keys are duplicate #165

Open
wenchy opened this issue Nov 20, 2024 · 0 comments

Comments

@wenchy
Copy link
Member

wenchy commented Nov 20, 2024

Should check one sheet with all other sheets and print duplicate keys in two sheets with book and sheet name.

// map-reduce: reduce results to one
mainMsg := dynamicpb.NewMessage(info.MD) // treat the first one as main msg
for i := 0; i < len(msgs); i++ {
msg := msgs[i]
err := xproto.Merge(mainMsg, msg.protomsg)
if err != nil {
if errors.Is(err, xproto.ErrDuplicateKey) {
// find the already existed key before
for j := 0; j < i; j++ {
prevMsg := msgs[j]
err := xproto.CheckMapDuplicateKey(prevMsg.protomsg, msg.protomsg)
if err != nil {
bookNames := prevMsg.bookName + ", " + msg.bookName
return nil, xerrors.WrapKV(err,
xerrors.KeyModule, xerrors.ModuleConf,
xerrors.KeyBookName, bookNames,
xerrors.KeySheetName, info.Opts.Name,
xerrors.KeyPBMessage, string(info.MD.Name()))
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant