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

[FEATURE] When a nested field has mismatched type print the full path to that nested field #52

Closed
abroglesc opened this issue Oct 26, 2020 · 5 comments

Comments

@abroglesc
Copy link
Contributor

Summary

In a complex structure like the following:

{
  "source_machine": {
    "port": 80
  },
  "dest_machine": {
    "port": "http-port"
  }
}

If there was an error with another log where dest_machine.port was an integer this would error and simply state something like:
Ignoring field with mismatched type: old=(hard,port,NULLABLE,STRING); new=(hard,port,NULLABLE,INTEGER)

At this point you are left to figure out which structure this port column actually exists in. This is a more simple example but as the schema grows and is more complex, this problem is harder to manually resolve.

Ideally, we can track the path to this using a JSON path or dpath expression. Something like dest_machine.port. This will likely take adding an additional argument to the recursive function merge_schema_entry. Something like a base_path=None and continually build up that base_path string in each recursive iteration so that it can be used in the errors like "{}.{}".format(base_path, new_name) and "{}.{}".format(base_path, old_name)

@bxparks
Copy link
Owner

bxparks commented Oct 26, 2020

I can't remember, does the script print out the line number of the record with the error? Does that help?

The JSON path to the error is a reasonable idea. I'm happy to review a PR if you have something in mind. Otherwise, it might take me a while to get to this, since it won't rise high on my priority list...

@bxparks
Copy link
Owner

bxparks commented Oct 26, 2020

Oh, I understand your problem, you have 2 port fields, so the line number does not help.

@abroglesc
Copy link
Contributor Author

@bxparks created #53 to address this.

@bxparks
Copy link
Owner

bxparks commented Oct 28, 2020

Fixed

@bxparks
Copy link
Owner

bxparks commented Oct 28, 2020

Pushed v1.2 to PyPI.

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

2 participants