This commit is contained in:
kssenii 2021-11-18 08:45:59 +00:00
parent 4016530b99
commit 11ab1f1ae5
3 changed files with 10 additions and 3 deletions

View File

@ -268,13 +268,15 @@ public:
out << current_element.getElement();
auto output_str = out.str();
ColumnString & col_str = assert_cast<ColumnString &>(dest);
ColumnString::Chars & data = col_str.getChars();
ColumnString::Offsets & offsets = col_str.getOffsets();
if (current_element.isString())
{
ReadBufferFromString buf(output_str);
String unquoted_output_str;
readJSONString(unquoted_output_str, buf);
col_str.insertData(unquoted_output_str.data(), unquoted_output_str.size());
readJSONStringInto(data, buf);
data.push_back(0);
offsets.push_back(data.size());
}
else
{

View File

@ -98,4 +98,8 @@ SELECT id, JSON_QUERY(json, '$.friends[0 to 2]') FROM 01889_sql_json ORDER BY id
0 ["Vasily", "Kostya"]
1 ["Tihon", "Ernest"]
2 ["Katya", "Anatoliy"]
SELECT id, JSON_VALUE(json, '$.friends[0]') FROM 01889_sql_json ORDER BY id;
0 Vasily
1 Tihon
2 Katya
DROP TABLE 01889_sql_json;

View File

@ -55,4 +55,5 @@ INSERT INTO 01889_sql_json(id, json) VALUES(0, '{"name":"Ivan","surname":"Ivanov
INSERT INTO 01889_sql_json(id, json) VALUES(1, '{"name":"Katya","surname":"Baltica","friends":["Tihon","Ernest","Innokentiy"]}');
INSERT INTO 01889_sql_json(id, json) VALUES(2, '{"name":"Vitali","surname":"Brown","friends":["Katya","Anatoliy","Ivan","Oleg"]}');
SELECT id, JSON_QUERY(json, '$.friends[0 to 2]') FROM 01889_sql_json ORDER BY id;
SELECT id, JSON_VALUE(json, '$.friends[0]') FROM 01889_sql_json ORDER BY id;
DROP TABLE 01889_sql_json;