-
Notifications
You must be signed in to change notification settings - Fork 66
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
Validation error thrown for number that should be recognized as a number? #290
Comments
right you are, this is most likely a bug in our csv schema detection. Given that you've provided example data we have everything we need to replicate see if we can't ship a fix in the next release (we're aiming for Monday). Thanks for filing @nathantchan! |
Great! So on further investigation, it looks like this is an issue with the dsio package. In order to use the jsonschema validator on CSV data, we manipulate the csv data into a slice of bytes using the dsio.NewValueReader and dsio.NewValueBuffer functions. NewValueReader, unfortunately, does not "encode" the way json.Marshal does. So, we end up with an array of strings, rather than an array of the most naturally fitting type. This creates the weird error in jsonschema. The schema specifies that it should be a number, but the data passed in has encoded it as a string. |
So, turns out a *bunch* of stuff needed fixing when it comes to valiation. We've gone through and cleanup up the following to make validation a better experience. jsonpointer: * added a new "Descendant" method on a pointer to generate child paths jsonschema: * complete overhaul of Validation interface to support multiple errors, consistent error formatting, and added a jsonpointer path to the location of each error dataset/dsio: * added a new "Entry" struct to represent top-level entries in a dataset * overhauled dsio to remove vals package. dsio now works with go prinitive types * CSVReader has been completely reworked to convert entry rows to the types specified by the Structure schema of the reader (this was the root cause of #290) dataset/validate: * added a new Data method that consumes a dsio.EntryReader to validate data that auto-converts incoming data to JSON for validation (a necessary step to work with JSONSchemas) dataset/dsfs: * dsfs.CreateDataset now uses validate.Data dataset: * updated all packages to use new dsio interfaces qri/core: * dataset.Validate now is mainly a wrapper around validate.Data This sets the stage for some exciting stuff in the future, and makes qri work properly / better today. I'm particularly excited to work with the new dsio Reader/Writer interfaces, as they set the stage for filtering & sorting subsections of datasets on the fly closes #290
I have a csv with two columns, the first of which is the number of seconds since the unix epoch began, with nanosecond decimals, and a float after it.
I added it to qri with the following command:
It threw a validation error:
Seems like this should be recognized as a number, though.
The text was updated successfully, but these errors were encountered: