From 59dfbe75bad2413daa5fbdf3e16f9ece0a28c124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 30 May 2022 09:07:05 +0200 Subject: [PATCH 1/3] json-functions: Update status and links --- functions-and-operators/json-functions.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/functions-and-operators/json-functions.md b/functions-and-operators/json-functions.md index 43d765cbff552..32459ebf0bff9 100644 --- a/functions-and-operators/json-functions.md +++ b/functions-and-operators/json-functions.md @@ -40,6 +40,7 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS | [JSON_ARRAY_INSERT(json_doc, path, val[, path, val] ...)][json_array_insert] | Inserts an array into the json document and returns the modified document | | [JSON_INSERT(json_doc, path, val[, path, val] ...)][json_insert] | Inserts data into a JSON document and returns the result | | [JSON_MERGE(json_doc, json_doc[, json_doc] ...)][json_merge] | A deprecated alias for `JSON_MERGE_PRESERVE` | +| [JSON_MERGE_PATCH(json_doc, json_doc[, json_doc] ...)][json_merge_patch] | Merge JSON documents | | [JSON_MERGE_PRESERVE(json_doc, json_doc[, json_doc] ...)][json_merge_preserve] | Merges two or more JSON documents and returns the merged result | | [JSON_REMOVE(json_doc, path[, path] ...)][json_remove] | Removes data from a JSON document and returns the result | | [JSON_REPLACE(json_doc, path, val[, path, val] ...)][json_replace] | Replaces existing values in a JSON document and returns the result | @@ -55,28 +56,22 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS | [JSON_DEPTH(json_doc)][json_depth] | Returns the maximum depth of a JSON document | | [JSON_LENGTH(json_doc[, path])][json_length] | Returns the length of a JSON document, or, if a path argument is given, the length of the value within the path | | [JSON_TYPE(json_val)][json_type] | Returns a string indicating the type of a JSON value | -| [JSON_VALID(json_doc)][json_valid] | Checks if a json_doc is valid JSON. Useful for checking a column before converting it to the json type. | +| [JSON_VALID(json_doc)][json_valid] | Checks if a json\_doc is valid JSON. Useful for checking a column before converting it to the json type. | ## Utility Functions | Function Name | Description | | --------------------------------- | ----------- | +| [JSON_PRETTY(json_doc)][json_pretty] | Pretty formatting of a JSON document | | [JSON_STORAGE_SIZE(json_doc)][json_storage_size] | Returns an approximate size of bytes required to store the json value. As the size does not account for TiKV using compression, the output of this function is not strictly compatible with MySQL. | ## Aggregate Functions | Function Name | Description | | --------------------------------- | ----------- | +| [JSON_ARRAYAGG(key)][json_arrayagg] | Provides an aggregation of keys. | | [JSON_OBJECTAGG(key, value)][json_objectagg] | Provides an aggregation of values for a given key. | -## Unsupported functions - -The following JSON functions are unsupported in TiDB. You can track the progress in adding them in [TiDB #7546](https://github.com/pingcap/tidb/issues/7546): - -* `JSON_MERGE_PATCH` -* `JSON_PRETTY` -* `JSON_ARRAYAGG` - ## See also * [JSON Function Reference](https://dev.mysql.com/doc/refman/5.7/en/json-function-reference.html) @@ -102,6 +97,8 @@ The following JSON functions are unsupported in TiDB. You can track the progress [json_merge]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge +[json_merge_patch]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge-patch + [json_merge_preserve]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge-preserve [json_object]: https://dev.mysql.com/doc/refman/5.7/en/json-creation-functions.html#function_json-object @@ -131,3 +128,11 @@ The following JSON functions are unsupported in TiDB. You can track the progress [json_array_append]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-array-append [json_array_insert]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-array-insert + +[json_arrayagg]: https://dev.mysql.com/doc/refman/5.7/en/aggregate-functions.html#function_json-arrayagg + +[json_objectagg]: https://dev.mysql.com/doc/refman/5.7/en/aggregate-functions.html#function_json-objectagg + +[json_pretty]: https://dev.mysql.com/doc/refman/5.7/en/json-utility-functions.html#function_json-pretty + +[json_storage_size]: https://dev.mysql.com/doc/refman/5.7/en/json-utility-functions.html#function_json-storage-size \ No newline at end of file From e2d440507a1bc8a63ed725ffd0a0cd8162eecb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 30 May 2022 09:41:42 +0200 Subject: [PATCH 2/3] Fix dead anchor --- functions-and-operators/json-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions-and-operators/json-functions.md b/functions-and-operators/json-functions.md index 32459ebf0bff9..9bd8059a41ee3 100644 --- a/functions-and-operators/json-functions.md +++ b/functions-and-operators/json-functions.md @@ -9,7 +9,7 @@ summary: Learn about JSON functions. > > This is still an experimental feature. It is **NOT** recommended that you use it in the production environment. -TiDB supports most of the JSON functions that shipped with the GA release of MySQL 5.7. Additional JSON functions were added to MySQL 5.7 after its release, and not all are available in TiDB (see [unsupported functions](#unsupported-functions)). +TiDB supports most of the JSON functions that shipped with the GA release of MySQL 5.7. ## Functions that create JSON values @@ -135,4 +135,4 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS [json_pretty]: https://dev.mysql.com/doc/refman/5.7/en/json-utility-functions.html#function_json-pretty -[json_storage_size]: https://dev.mysql.com/doc/refman/5.7/en/json-utility-functions.html#function_json-storage-size \ No newline at end of file +[json_storage_size]: https://dev.mysql.com/doc/refman/5.7/en/json-utility-functions.html#function_json-storage-size From 0ca231fd3bbb067fba1c5b743ad7c57e81a51f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 20 Jun 2022 08:07:34 +0200 Subject: [PATCH 3/3] Adjust for v5.1.x --- functions-and-operators/json-functions.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/functions-and-operators/json-functions.md b/functions-and-operators/json-functions.md index 9bd8059a41ee3..94ed7f2343f16 100644 --- a/functions-and-operators/json-functions.md +++ b/functions-and-operators/json-functions.md @@ -9,7 +9,7 @@ summary: Learn about JSON functions. > > This is still an experimental feature. It is **NOT** recommended that you use it in the production environment. -TiDB supports most of the JSON functions that shipped with the GA release of MySQL 5.7. +TiDB supports most of the JSON functions that shipped with the GA release of MySQL 5.7. Additional JSON functions were added to MySQL 5.7 after its release, and not all are available in TiDB (see [unsupported functions](#unsupported-functions)). ## Functions that create JSON values @@ -40,7 +40,6 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS | [JSON_ARRAY_INSERT(json_doc, path, val[, path, val] ...)][json_array_insert] | Inserts an array into the json document and returns the modified document | | [JSON_INSERT(json_doc, path, val[, path, val] ...)][json_insert] | Inserts data into a JSON document and returns the result | | [JSON_MERGE(json_doc, json_doc[, json_doc] ...)][json_merge] | A deprecated alias for `JSON_MERGE_PRESERVE` | -| [JSON_MERGE_PATCH(json_doc, json_doc[, json_doc] ...)][json_merge_patch] | Merge JSON documents | | [JSON_MERGE_PRESERVE(json_doc, json_doc[, json_doc] ...)][json_merge_preserve] | Merges two or more JSON documents and returns the merged result | | [JSON_REMOVE(json_doc, path[, path] ...)][json_remove] | Removes data from a JSON document and returns the result | | [JSON_REPLACE(json_doc, path, val[, path, val] ...)][json_replace] | Replaces existing values in a JSON document and returns the result | @@ -69,9 +68,15 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS | Function Name | Description | | --------------------------------- | ----------- | -| [JSON_ARRAYAGG(key)][json_arrayagg] | Provides an aggregation of keys. | | [JSON_OBJECTAGG(key, value)][json_objectagg] | Provides an aggregation of values for a given key. | +## Unsupported functions + +The following JSON functions are unsupported in TiDB. You can track the progress in adding them in [TiDB #7546](https://github.com/pingcap/tidb/issues/7546): + +* `JSON_MERGE_PATCH` +* `JSON_ARRAYAGG` + ## See also * [JSON Function Reference](https://dev.mysql.com/doc/refman/5.7/en/json-function-reference.html) @@ -97,8 +102,6 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS [json_merge]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge -[json_merge_patch]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge-patch - [json_merge_preserve]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-merge-preserve [json_object]: https://dev.mysql.com/doc/refman/5.7/en/json-creation-functions.html#function_json-object @@ -129,8 +132,6 @@ TiDB supports most of the JSON functions that shipped with the GA release of MyS [json_array_insert]: https://dev.mysql.com/doc/refman/5.7/en/json-modification-functions.html#function_json-array-insert -[json_arrayagg]: https://dev.mysql.com/doc/refman/5.7/en/aggregate-functions.html#function_json-arrayagg - [json_objectagg]: https://dev.mysql.com/doc/refman/5.7/en/aggregate-functions.html#function_json-objectagg [json_pretty]: https://dev.mysql.com/doc/refman/5.7/en/json-utility-functions.html#function_json-pretty