ClickHouse / ClickHouse/ClickHouse
Function `JSONSchema`
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
**Use case**
Currently there is a function `JSONType`, but it is not recursive and returns single type for specific path. Sometimes it's useful to get the full schema of JSON document.
**Describe the solution you'd like**
Use simple subset of JSON Schema format (https://json-schema.org) -- only `type`, `properties` and `items` keywords.
E.g for document:
```json
{
"firstName": "Joe",
"lastName": "Jackson",
"gender": "male",
"age": 28,
"address": {
"streetAddress": "101",
"city": "San Diego",
"state": "CA"
},
"phoneNumbers": [
{ "type": "home", "number": "7349282382" }
]
}
```
generate schema:
```json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"gender": {
"type": "string"
},
"age": {
"type": "integer"
},
"address": {
"type": "object",
"properties": {
"streetAddress": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
}
}
},
"phoneNumbers": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"number": {
"type": "string"
}
}
}
]
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.