Add support for Chinese components in Nested data types

This commit is contained in:
Alexey Milovidov 2021-07-03 03:13:21 +03:00
parent 1e9fbdb02c
commit b26feb2b19
3 changed files with 24 additions and 30 deletions

View File

@ -34,41 +34,15 @@ std::string concatenateName(const std::string & nested_table_name, const std::st
}
/** Name can be treated as compound if and only if both parts are simple identifiers.
/** Name can be treated as compound if it contains dot (.) in the middle.
*/
std::pair<std::string, std::string> splitName(const std::string & name)
{
const char * begin = name.data();
const char * pos = begin;
const char * end = begin + name.size();
if (pos >= end || !isValidIdentifierBegin(*pos))
auto idx = name.find_first_of('.');
if (idx == std::string::npos || idx == 0 || idx + 1 == name.size())
return {name, {}};
++pos;
while (pos < end && isWordCharASCII(*pos))
++pos;
if (pos >= end || *pos != '.')
return {name, {}};
const char * first_end = pos;
++pos;
const char * second_begin = pos;
if (pos >= end || !isValidIdentifierBegin(*pos))
return {name, {}};
++pos;
while (pos < end && isWordCharASCII(*pos))
++pos;
if (pos != end)
return {name, {}};
return {{ begin, first_end }, { second_begin, end }};
return {name.substr(0, idx), name.substr(idx + 1)};
}

View File

@ -0,0 +1,12 @@
id String
products.产品 Array(Array(String))
products.销量 Array(Array(Int32))
id String
products.产品 Array(Array(String))
products.销量 Array(Array(Int32))
id String
products.产品 Array(String)
products.销量 Array(Int32)
p.产品 Array(String)
p.销量 Array(Int32)
0

View File

@ -0,0 +1,8 @@
CREATE TEMPORARY TABLE test (`id` String, `products` Nested (`` Array(String), `` Array(Int32)));
DESCRIBE test;
DESCRIBE (SELECT * FROM test);
DESCRIBE (SELECT * FROM test ARRAY JOIN products);
DESCRIBE (SELECT p.``, p.`` FROM test ARRAY JOIN products AS p);
SELECT * FROM test ARRAY JOIN products;
SELECT count() FROM (SELECT * FROM test ARRAY JOIN products);