Merge pull request #25923 from ClickHouse/nested-chinese

Add support for Chinese components in `Nested` data types
This commit is contained in:
Maksim Kita 2021-07-03 14:51:37 +03:00 committed by GitHub
commit f238d98fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);