-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add itemType
constraint to array
type
#409
Add itemType
constraint to array
type
#409
Comments
@akariv really like it. Again may be v1.1 |
Related: #381 |
+1 on this, and we should do a PR once v1 settles. |
@akariv would you be up for doing a PR to implement this? I also think that rather than just have the type we might as well go the whole hog and just have the whole field schema be reused for the individual item. In this case the property name might be something like an Alternatively, since most of the constraints in constraints only make sense for individual values we could implicitly apply them to the individual values in the array e.g. max, min, enum etc in which case we do only need Thoughts @roll ... |
@rufuspollock that's my suggestion in #410 |
Isn't the difference that for array all entries are implicitly of the same
type?
…On Thu, Apr 30, 2020 at 9:44 PM Adam Kariv ***@***.***> wrote:
@rufuspollock <https://github.com/rufuspollock> that's my suggestion in
#410 <#410>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#409 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABMDMWJTBM4NABT36V6N53RPHIKXANCNFSM4DJSDHSQ>
.
|
In both cases the datatype is the same in all array entries. |
I think |
I think there are two options Simple
Because it's a JSON we can probably treat items just as native JSON values (
It will mean no processing on the TableSchema level but just checking that a JSON has items with the same given type e.g. We can also add a This option will keep things simple. ComplexAnother option is to have full With the second option, we add an ability to process array's items with all the power of Table Schema. This option is much more complex though. |
I think that `itemType` should have the same semantics as `type` (i.e.read a tableschema type name and not a json).
Array items would then be considered as physical representation and would
be processed to extract the logical value.
But then, we would need also `itemConstraints`, `itemFormat`, `itemDecimalChar` and there's no end to this.
Therefore, a different proposal for this would be to create a single `arrayItem` configuration, which is parsed exactly as a tableschema field.
Like so:
```
...
{
"name": "futurePaymentDates",
"type": "array",
"constraints": {
"maxLength": 12
},
"arrayItem": {
"type": "date",
"format": "%Y/%m/%d"
}
}
```
This also means that `schema`, as a field specification, might be added to the spec as an optional parameter of an `object` field - but is unrelated to the `array` item issue.
|
Yea exactly, without all the options a Table Schema type is partially useless.
It can be
I'm not sure that it's the best option just trying to figure out the pros. |
There is something elegant in reusing the existing schema structures when adding this feature. I don't think constraining the arrays to simple JSON types would provide a lot of value. I favor @akariv's proposal. |
OK, it looks like we have convergence here. |
I see frictionlessdata/frictionless-py#627 has been referenced here but it solves a fundamentally different issue. It would be great to see this original request added. It is very common that members of an array be same typed, and declaring it as part of table schema would allow:
Note that this behavior ( also #410 ) is already implemented in some form in https://github.com/frictionlessdata/tableschema-elasticsearch-py and has a bunch of successful usage in production systems. |
Happy to have PRs on this - or even start with a pattern and implement into say python. Remember the complex thing with the specs now is that one then needs all drivers to upgrade to be compliant. |
This attribute will allow specifying the exact items that are allowed in an array.
e.g.
Related
Doing this with appropriate semantics would also resolve
The text was updated successfully, but these errors were encountered: