mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-21 19:45:56 +03:00
The following functions are created: Create function JSON_VALID and test cases Create function JSON_DEPTH and test cases Create function JSON_LENGTH and test cases Create function JSON_EQUALS and test cases Create function JSON_NORMALIZE and test cases Create function JSON_TYPE and test cases Create function JSON_OBJECT and test cases Create function JSON_ARRAY and test cases Create function JSON_KEYS and test cases Create function JSON_EXISTS and test cases Create function JSON_QUOTE/JSON_UNQUOTE and test cases Create function JSON_COMPACT/DETAILED/LOOSE and test cases Create function JSON_MERGE and test cases Create function JSON_MERGE_PATCH and test cases Create function JSON_VALUE and test cases Create function JSON_QUERY and test cases Create function JSON_CONTAINS and test cases Create function JSON_ARRAY_APPEND and test cases Create function JSON_ARRAY_INSERT and test cases Create function JSON_INSERT/REPLACE/SET and test cases Create function JSON_REMOVE and test cases Create function JSON_CONTAINS_PATH and test cases Create function JSON_OVERLAPS and test cases Create function JSON_EXTRACT and test cases Create function JSON_SEARCH and test cases Note: Some functions output differs from MDB because session variables that affects functions output,e.g JSON_QUOTE/JSON_UNQUOTE This depends on MCOL-5212
183 lines
4.0 KiB
Plaintext
183 lines
4.0 KiB
Plaintext
--source ../include/disable_before_10.9.inc
|
|
--source ../include/have_columnstore.inc
|
|
--disable_warnings
|
|
DROP DATABASE IF EXISTS json_overlaps_db;
|
|
|
|
--enable_warnings
|
|
CREATE DATABASE json_overlaps_db;
|
|
|
|
USE json_overlaps_db;
|
|
|
|
--echo # ----------------------------------------------------------------------
|
|
--echo # Test of JSON_OVERLAPS function.
|
|
--echo # ----------------------------------------------------------------------
|
|
--echo # Comparing scalar
|
|
CREATE TABLE t1(l1 LONGTEXT, l2 LONGTEXT) ENGINE = COLUMNSTORE;
|
|
|
|
INSERT INTO
|
|
t1
|
|
VALUES
|
|
('true', 'true'),
|
|
('false', 'false'),
|
|
('1', '1'),
|
|
('"string1"', '"string1"'),
|
|
('null', 'null'),
|
|
('true', 'false'),
|
|
('1', '"1"'),
|
|
('1', '0'),
|
|
('null', '0'),
|
|
('"string1"', '"string2"'),
|
|
('true', '["abc", 1, 2, true, false]'),
|
|
('true', '["abc", 1, 2, [true]]'),
|
|
('true', '{"A":true}');
|
|
|
|
SELECT
|
|
l1,
|
|
l2,
|
|
JSON_OVERLAPS(l1, l2) AS is_overlaps
|
|
FROM
|
|
t1;
|
|
|
|
--echo # Testing non-scalar json data types
|
|
--echo # Comparing object with object (non-nested)
|
|
CREATE TABLE t2(l1 LONGTEXT, l2 LONGTEXT) ENGINE = COLUMNSTORE;
|
|
|
|
INSERT INTO
|
|
t2
|
|
VALUES
|
|
('{"A":[1, 2, 3]}', '{}'),
|
|
('{"A": 1}', '{"A": 1}'),
|
|
('{"A": 1}', '{"B": 1}'),
|
|
(
|
|
'{"A": 1, "B": "string1"}',
|
|
'{"A": 2,"B": "string1"}'
|
|
),
|
|
(
|
|
'{"A": 1,"B": "string1"}',
|
|
'{"A": 2,"B": "string2"}'
|
|
),
|
|
(
|
|
'{"A": 1,"B": {"C":2}}',
|
|
'{"A": 2,"B": {"C":1}}'
|
|
),
|
|
(
|
|
'{"A": 1,"B": {"C":2}}',
|
|
'{"A": 2,"B": {"C":2}}'
|
|
),
|
|
(
|
|
'{"A": {"B": true}}',
|
|
'{"A": {"B": true,"C": false}}'
|
|
),
|
|
(
|
|
'{"A":1, "B":{"D":4, "E":5}}',
|
|
'{"C":3, "B":{"E":5, "D":4}}'
|
|
),
|
|
(
|
|
'{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
|
'{"C":3, "B":{"E":5, "D":4}}'
|
|
),
|
|
(
|
|
'{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
|
'{"C":3, "B":{"E":[5, 6, 7], "D":4}}'
|
|
),
|
|
(
|
|
'{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
|
'{"C":3, "B":{"E":[7, 6 ,5], "D":4}}'
|
|
),
|
|
(
|
|
'{"A":1, "B":{"D":4, "E":[5, 6, 7]}}',
|
|
'{"C":3, "F":{"E":[5, 6, 7], "D":4}}'
|
|
),
|
|
('[1, 2, true, false, null]', '[3, 4, 1]'),
|
|
('[1, 2, true, false, null]', '[3, 4, 5]'),
|
|
('[1,2,3]', '[]'),
|
|
('[1, 2, true, false, null]', '[3, 4, [1]]'),
|
|
(
|
|
'[1, 2, [true, false], null]',
|
|
'[[1], [true, false]]'
|
|
),
|
|
('[1, 2, 3, [4, 5, 6]]', '[7, 8, 9, [6, 5, 4]]'),
|
|
('[1, 2, true, false, null]', '{"A": 1}'),
|
|
(
|
|
'[1, 2, true, false, null, {"A":2}]',
|
|
'{"A": 1}'
|
|
),
|
|
('[1, {"A": 2}, {"A": 1}]', '{"A": 1}'),
|
|
(
|
|
'[1, 2, true, false, {"A": 1, "B": 2}]',
|
|
'{"A": 1, "B": 2}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, {"A": 1, "B": 2}]',
|
|
'{"A": 1, "B": 3}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, [{"A": 1, "B": 2}]]',
|
|
'{"A": 1, "B": 2}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, [{"A": 1, "B": 2}]]',
|
|
'{"A": 1, "B": 3}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, [{"A": 1, "B": 2}]]',
|
|
'{"A": 1}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, {"A": 1, "B": {"C": 12}}]',
|
|
'{"A": 1, "B": {"C": 12}}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, [{"A": 1, "B": {"C": 12}}]]',
|
|
'{"A": 1, "B": {"C": 12}}'
|
|
),
|
|
(
|
|
'[1, 2, true, false, [{"A": 1, "B": {"C": 12}}]]',
|
|
'{"A": 1, "B":{"C": 12}}'
|
|
),
|
|
(
|
|
'[[1, 2, true, false, {"A": 1, "B": {"C": 12}}]]',
|
|
'{"A": 1, "B": {"C": 12}}'
|
|
),
|
|
(
|
|
'{"A": 1, "B": 3}',
|
|
'[1, 2, true, false, {"A": 1, "B": 2}]'
|
|
),
|
|
(
|
|
'{"A": 1, "B": 3}',
|
|
'[1, 2, true, false, {"A": 1, "B": 3}]'
|
|
),
|
|
(
|
|
'{"A": 1, "B": 3}',
|
|
'[1, 2, true, false, {"A": 1, "B": 2}, {"A": 1, "B": 3}]'
|
|
),
|
|
(
|
|
'{"A": 1, "B": [1, 2, 3]}',
|
|
'[1, 2, true, false, {"A": 1, "B": 2}, {"A": 1, "B": [1, 2, 3]}]'
|
|
),
|
|
(
|
|
'{"A": 1, "B": [1, 2, {"C": 3, "D": 5}]}',
|
|
'[1, 2, true, false, {"A": 1, "B": 2}, {"A":1, "B":[1, 2, {"C": 3, "D": 5}]}]'
|
|
),
|
|
(
|
|
'{"A": 1, "B": [1, 2, {"C": 3, "D": 5}]}',
|
|
'[1, 2, true, false, {"A": 1, "B": 2},{"A": 1, "B": [1, 2, {"C": 3, "D": 4}]}]'
|
|
),
|
|
(
|
|
'{"A": 1, "B": 3}',
|
|
'[1, 2, true, false, [{"A": 1, "B": 2}, {"A": 1, "B": 3}]]'
|
|
);
|
|
|
|
SELECT
|
|
l1,
|
|
l2,
|
|
JSON_OVERLAPS(l1, l2) AS is_overlaps
|
|
FROM
|
|
t2;
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP DATABASE json_overlaps_db;
|