diff --git a/CHANGELOG.md b/CHANGELOG.md index 9950d6d..78c9312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ The public API SHOULD NOT be considered stable. - AWS Kinesis Data Streams server support - field.links attribute - Trino support +- Field `type: map` support with properties `keys` and `values` +- Definitions: `fields`, for type `object`, `record`, and `struct` ## [0.9.3] - 2024-03-06 diff --git a/README.md b/README.md index de86652..d97ed82 100644 --- a/README.md +++ b/README.md @@ -583,10 +583,12 @@ The Field Objects describes one field (column, property, nested field) of a data | pii | `boolean` | An indication, if this field contains Personal Identifiable Information (PII). | | classification | `string` | The data class defining the sensitivity level for this field, according to the organization's classification scheme. Examples may be: `sensitive`, `restricted`, `internal`, `public`. | | tags | Array of `string` | Custom metadata to provide additional context. | -| links | Map[`string`,`string`] | Additional external documentation links. | +| links | Map[`string`,`string`] | Additional external documentation links. | | $ref | `string` | A reference URI to a definition in the specification, internally or externally. Properties will be inherited from the definition. | -| fields | Map[`string`, [Field Object](#field-object)] | The nested fields (e.g. columns) of the object, record, or struct. Use only when type is object, record, or struct. | -| items | [Field Object](#field-object) | The type of the elements in the array. Use only when type is array. | +| fields | Map[`string`, [Field Object](#field-object)] | The nested fields (e.g. columns) of the object, record, or struct. Use only when type is `object`, `record`, or `struct`. | +| items | [Field Object](#field-object) | The type of the elements in the array. Use only when type is `array`. | +| keys | [Field Object](#field-object) | Describes the key structure of a map. Defaults to `type: string` if a map is defined as type. Not all server types support different key types. Use only when type is `map`. | +| values | [Field Object](#field-object) | Describes the value structure of a map. Use only when type is `map`. | | config | [Config Object](#config-object) | Any additional key-value pairs that might be useful for further tooling. | @@ -596,29 +598,33 @@ The Definition Object includes a clear and concise explanations of syntax, seman It serves as a reference for a common understanding of terminology, ensure consistent usage and to identify join-able fields. Models fields can refer to definitions using the `$ref` field to link to existing definitions and avoid duplicate documentations. -| Field | Type | Description | -|------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| name | `string` | REQUIRED. The technical name of this definition. | -| type | [Data Type](#data-types) | REQUIRED. The logical data type | -| domain | `string` | The domain in which this definition is valid. Default: `global`. | -| title | `string` | The business name of this definition. | -| description | `string` | Clear and concise explanations related to the domain | -| enum | array of `string` | A value must be equal to one of the elements in this array value. Only evaluated if the value is not null. | -| format | `string` | `email`: A value must be complaint to [RFC 5321, section 4.1.2](https://www.rfc-editor.org/info/rfc5321).
`uri`: A value must be complaint to [RFC 3986](https://www.rfc-editor.org/info/rfc3986).
`uuid`: A value must be complaint to [RFC 4122](https://www.rfc-editor.org/info/rfc4122). Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | -| precision | `number` | The maximum number of digits in a number. Only applies to numeric values. Defaults to 38. | -| scale | `number` | The maximum number of decimal places in a number. Only applies to numeric values. Defaults to 0. | -| minLength | `number` | A value must greater than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | -| maxLength | `number` | A value must less than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | -| pattern | `string` | A value must be valid according to the [ECMA-262](https://262.ecma-international.org/5.1/) regular expression dialect. Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | -| minimum | `number` | A value of a number must greater than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to numeric values. | -| exclusiveMinimum | `number` | A value of a number must greater than the value of this. Only evaluated if the value is not null. Only applies to numeric values. | -| maximum | `number` | A value of a number must less than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to numeric values. | -| exclusiveMaximum | `number` | A value of a number must less than the value of this. Only evaluated if the value is not null. Only applies to numeric values. | -| example | `string` | An example value. | -| pii | `boolean` | An indication, if this field contains Personal Identifiable Information (PII). | -| classification | `string` | The data class defining the sensitivity level for this field, according to the organization's classification scheme. | -| tags | Array of `string` | Custom metadata to provide additional context. | -| links | Map[`string`, `string`] | Additional external documentation links. | +| Field | Type | Description | +|------------------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| name | `string` | REQUIRED. The technical name of this definition. | +| type | [Data Type](#data-types) | REQUIRED. The logical data type | +| domain | `string` | The domain in which this definition is valid. Default: `global`. | +| title | `string` | The business name of this definition. | +| description | `string` | Clear and concise explanations related to the domain | +| enum | array of `string` | A value must be equal to one of the elements in this array value. Only evaluated if the value is not null. | +| format | `string` | `email`: A value must be complaint to [RFC 5321, section 4.1.2](https://www.rfc-editor.org/info/rfc5321).
`uri`: A value must be complaint to [RFC 3986](https://www.rfc-editor.org/info/rfc3986).
`uuid`: A value must be complaint to [RFC 4122](https://www.rfc-editor.org/info/rfc4122). Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | +| precision | `number` | The maximum number of digits in a number. Only applies to numeric values. Defaults to 38. | +| scale | `number` | The maximum number of decimal places in a number. Only applies to numeric values. Defaults to 0. | +| minLength | `number` | A value must greater than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | +| maxLength | `number` | A value must less than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | +| pattern | `string` | A value must be valid according to the [ECMA-262](https://262.ecma-international.org/5.1/) regular expression dialect. Only evaluated if the value is not null. Only applies to unicode character sequences types (`string`, `text`, `varchar`). | +| minimum | `number` | A value of a number must greater than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to numeric values. | +| exclusiveMinimum | `number` | A value of a number must greater than the value of this. Only evaluated if the value is not null. Only applies to numeric values. | +| maximum | `number` | A value of a number must less than, or equal to, the value of this. Only evaluated if the value is not null. Only applies to numeric values. | +| exclusiveMaximum | `number` | A value of a number must less than the value of this. Only evaluated if the value is not null. Only applies to numeric values. | +| example | `string` | An example value. | +| pii | `boolean` | An indication, if this field contains Personal Identifiable Information (PII). | +| classification | `string` | The data class defining the sensitivity level for this field, according to the organization's classification scheme. | +| tags | Array of `string` | Custom metadata to provide additional context. | +| links | Map[`string`, `string`] | Additional external documentation links. | +| fields | Map[`string`, [Field Object](#field-object)] | The nested fields (e.g. columns) of the object, record, or struct. Use only when type is `object`, `record`, or `struct`. | +| items | [Field Object](#field-object) | The type of the elements in the array. Use only when type is `array`. | +| keys | [Field Object](#field-object) | Describes the key structure of a map. Defaults to `type: string` if a map is defined as type. Not all server types support different key types. Use only when type is `map`. | +| values | [Field Object](#field-object) | Describes the value structure of a map. Use only when type is `map`. | @@ -1111,6 +1117,7 @@ The following data types are supported for model fields and definitions: - Timestamp with no timezone: `timestamp_ntz` - Date with no time information: `date` - Array: `array` +- Map: `map` (may not be supported by some server types) - Sequence of 8-bit unsigned bytes: `bytes` - Complex type: `object`, `record`, `struct` - No value: `null` diff --git a/datacontract.schema.json b/datacontract.schema.json index 1ae6dcb..d74f637 100644 --- a/datacontract.schema.json +++ b/datacontract.schema.json @@ -821,6 +821,12 @@ "items": { "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" }, + "keys": { + "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" + }, + "values": { + "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" + }, "primary": { "type": "boolean", "default": false, @@ -985,7 +991,7 @@ "type": "string", "description": "Specify the physical column type that is used in a SQL Server table, e.g., `DATETIME2`." }, - "unityType": { + "databricksType": { "type": "string", "description": "Specify the physical column type that is used in a Databricks Unity Catalog table." }, @@ -1053,6 +1059,22 @@ "type": { "$ref": "#/$defs/FieldType" }, + "fields": { + "description": "The nested fields (e.g. columns) of the object, record, or struct.", + "type": "object", + "additionalProperties": { + "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" + } + }, + "items": { + "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" + }, + "keys": { + "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" + }, + "values": { + "$ref": "#/properties/models/additionalProperties/properties/fields/additionalProperties" + }, "minLength": { "type": "integer", "description": "A value must be greater than or equal to this value. Applies only to string types." @@ -1495,6 +1517,7 @@ "timestamp_ntz", "date", "array", + "map", "object", "record", "struct",