You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-785 Implement DISTRIBUTED JSON functions
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
This commit is contained in:
191
mysql-test/columnstore/basic/r/func_json_valid.result
Normal file
191
mysql-test/columnstore/basic/r/func_json_valid.result
Normal file
@ -0,0 +1,191 @@
|
||||
DROP DATABASE IF EXISTS json_valid_db;
|
||||
CREATE DATABASE json_valid_db;
|
||||
USE json_valid_db;
|
||||
# ----------------------------------------------------------------------
|
||||
# Test of JSON_VALID function.
|
||||
# ----------------------------------------------------------------------
|
||||
#
|
||||
# String literal - valid JSON
|
||||
#
|
||||
CREATE TABLE t1(l LONGTEXT) ENGINE = COLUMNSTORE;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
('123'),
|
||||
('-123'),
|
||||
('5000000000'),
|
||||
('-5000000000'),
|
||||
('1.23'),
|
||||
('"123"'),
|
||||
('true'),
|
||||
('false'),
|
||||
('null'),
|
||||
('{"address": "Trondheim"}'),
|
||||
(JSON_OBJECT()),
|
||||
(JSON_OBJECT(1, 2)),
|
||||
(JSON_ARRAY()),
|
||||
(JSON_ARRAY(1, 2));
|
||||
SELECT
|
||||
l AS raw,
|
||||
JSON_VALID(l) AS is_valid,
|
||||
JSON_VALID(JSON_COMPACT(l)) AS compact
|
||||
FROM
|
||||
t1;
|
||||
raw is_valid compact
|
||||
123 1 1
|
||||
-123 1 1
|
||||
5000000000 1 1
|
||||
-5000000000 1 1
|
||||
1.23 1 1
|
||||
"123" 1 1
|
||||
true 1 1
|
||||
false 1 1
|
||||
null 1 1
|
||||
{"address": "Trondheim"} 1 1
|
||||
{} 1 1
|
||||
{"1": 2} 1 1
|
||||
[] 1 1
|
||||
[1, 2] 1 1
|
||||
#
|
||||
# String literal - invalid JSON
|
||||
#
|
||||
TRUNCATE t1;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
('12 3'),
|
||||
('{key:value}'),
|
||||
('{key:value'),
|
||||
('[1,2,]'),
|
||||
('[1,2');
|
||||
SELECT
|
||||
l AS raw,
|
||||
JSON_VALID(l) AS is_valid,
|
||||
JSON_VALID(JSON_COMPACT(l)) AS compact
|
||||
FROM
|
||||
t1;
|
||||
raw is_valid compact
|
||||
12 3 0 NULL
|
||||
{key:value} 0 NULL
|
||||
{key:value 0 NULL
|
||||
[1,2,] 0 NULL
|
||||
[1,2 0 NULL
|
||||
#
|
||||
# String literal - not in UTF-8
|
||||
#
|
||||
TRUNCATE t1;
|
||||
SET
|
||||
NAMES 'ascii';
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
('123');
|
||||
SELECT
|
||||
l AS raw,
|
||||
JSON_VALID(l) AS is_valid,
|
||||
JSON_VALID(JSON_COMPACT(l)) AS compact
|
||||
FROM
|
||||
t1;
|
||||
raw is_valid compact
|
||||
123 1 1
|
||||
SET
|
||||
NAMES 'utf8';
|
||||
#
|
||||
# Bare NULL
|
||||
#
|
||||
TRUNCATE t1;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(NULL);
|
||||
SELECT
|
||||
JSON_VALID(l)
|
||||
FROM
|
||||
t1;
|
||||
JSON_VALID(l)
|
||||
NULL
|
||||
#
|
||||
# Function result - string
|
||||
#
|
||||
TRUNCATE t1;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(UPPER('"abc"'));
|
||||
SELECT
|
||||
JSON_VALID(l)
|
||||
FROM
|
||||
t1;
|
||||
JSON_VALID(l)
|
||||
1
|
||||
#
|
||||
# Function result - string not in UTF-8
|
||||
#
|
||||
TRUNCATE t1;
|
||||
SET
|
||||
NAMES 'latin1';
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(UPPER('"abc"'));
|
||||
SELECT
|
||||
JSON_VALID(l)
|
||||
FROM
|
||||
t1;
|
||||
JSON_VALID(l)
|
||||
1
|
||||
SET
|
||||
NAMES 'utf8';
|
||||
#
|
||||
# Function result - date, not valid as JSON without CAST
|
||||
#
|
||||
TRUNCATE t1;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(CAST('2015-01-15' AS DATE));
|
||||
SELECT
|
||||
JSON_VALID(l)
|
||||
FROM
|
||||
t1;
|
||||
JSON_VALID(l)
|
||||
0
|
||||
#
|
||||
# The date string doesn't parse as JSON text, so wrong:
|
||||
#
|
||||
TRUNCATE t1;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(
|
||||
CAST(
|
||||
CAST('2015-01-15' AS DATE) AS CHAR CHARACTER SET 'utf8'
|
||||
)
|
||||
);
|
||||
SELECT
|
||||
JSON_VALID(l)
|
||||
FROM
|
||||
t1;
|
||||
JSON_VALID(l)
|
||||
0
|
||||
#
|
||||
# Function result - NULL
|
||||
#
|
||||
TRUNCATE t1;
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(UPPER(NULL));
|
||||
INSERT INTO
|
||||
t1
|
||||
VALUES
|
||||
(UPPER(CAST(NULL AS CHAR)));
|
||||
SELECT
|
||||
JSON_VALID(l)
|
||||
FROM
|
||||
t1;
|
||||
JSON_VALID(l)
|
||||
NULL
|
||||
NULL
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE json_valid_db;
|
Reference in New Issue
Block a user