Split Dynamic subcolumn name into 2 parts: type name and subcolumn of this type. We cannot simply split by '.' because type name can also contain dots. For example: Tuple(`a.b` UInt32). But in all such cases this '.' will be inside back quotes. To split subcolumn name correctly we search for the first '.' that is not inside back quotes.
| 851 | /// But in all such cases this '.' will be inside back quotes. To split subcolumn name correctly |
| 852 | /// we search for the first '.' that is not inside back quotes. |
| 853 | std::pair<std::string_view, std::string_view> splitSubcolumnName(std::string_view subcolumn_name) |
| 854 | { |
| 855 | bool inside_quotes = false; |
| 856 | const char * pos = subcolumn_name.data(); |
| 857 | const char * end = subcolumn_name.data() + subcolumn_name.size(); |
| 858 | while (true) |
| 859 | { |
| 860 | pos = find_first_symbols<'`', '.', '\\'>(pos, end); |
| 861 | if (pos == end) |
| 862 | break; |
| 863 | |
| 864 | if (*pos == '`') |
| 865 | { |
| 866 | inside_quotes = !inside_quotes; |
| 867 | ++pos; |
| 868 | } |
| 869 | else if (*pos == '\\') |
| 870 | { |
| 871 | ++pos; |
| 872 | } |
| 873 | else if (*pos == '.') |
| 874 | { |
| 875 | if (inside_quotes) |
| 876 | ++pos; |
| 877 | else |
| 878 | break; |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | if (pos == end) |
| 883 | return {subcolumn_name, {}}; |
| 884 | |
| 885 | return {std::string_view(subcolumn_name.data(), pos), std::string_view(pos + 1, end)}; /// NOLINT(bugprone-suspicious-stringview-data-usage) |
| 886 | } |
| 887 | |
| 888 | } |
| 889 |
no test coverage detected