mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #71359 from ClickHouse/backport/24.8/71182
Backport #71182 to 24.8: Escape special symbols in files for JSON subcolumns
This commit is contained in:
commit
f3d4236ce2
@ -162,7 +162,7 @@ String getNameForSubstreamPath(
|
||||
String stream_name,
|
||||
SubstreamIterator begin,
|
||||
SubstreamIterator end,
|
||||
bool escape_tuple_delimiter)
|
||||
bool escape_for_file_name)
|
||||
{
|
||||
using Substream = ISerialization::Substream;
|
||||
|
||||
@ -187,7 +187,7 @@ String getNameForSubstreamPath(
|
||||
/// Because nested data may be represented not by Array of Tuple,
|
||||
/// but by separate Array columns with names in a form of a.b,
|
||||
/// and name is encoded as a whole.
|
||||
if (it->type == Substream::TupleElement && escape_tuple_delimiter)
|
||||
if (it->type == Substream::TupleElement && escape_for_file_name)
|
||||
stream_name += escapeForFileName(substream_name);
|
||||
else
|
||||
stream_name += substream_name;
|
||||
@ -207,7 +207,7 @@ String getNameForSubstreamPath(
|
||||
else if (it->type == SubstreamType::ObjectSharedData)
|
||||
stream_name += ".object_shared_data";
|
||||
else if (it->type == SubstreamType::ObjectTypedPath || it->type == SubstreamType::ObjectDynamicPath)
|
||||
stream_name += "." + it->object_path_name;
|
||||
stream_name += "." + (escape_for_file_name ? escapeForFileName(it->object_path_name) : it->object_path_name);
|
||||
}
|
||||
|
||||
return stream_name;
|
||||
|
@ -0,0 +1,3 @@
|
||||
{"a-b-c":"43","a-b\\/c-d\\/e":"44","a\\/b\\/c":"42"}
|
||||
42 43 44
|
||||
42 43 44
|
10
tests/queries/0_stateless/03257_json_escape_file_names.sql
Normal file
10
tests/queries/0_stateless/03257_json_escape_file_names.sql
Normal file
@ -0,0 +1,10 @@
|
||||
set allow_experimental_json_type = 1;
|
||||
drop table if exists test;
|
||||
create table test (json JSON) engine=MergeTree order by tuple() settings min_rows_for_wide_part=0, min_bytes_for_wide_part=0;
|
||||
insert into test format JSONAsObject {"a/b/c" : 42, "a-b-c" : 43, "a-b/c-d/e" : 44};
|
||||
|
||||
select * from test;
|
||||
select json.`a/b/c`, json.`a-b-c`, json.`a-b/c-d/e` from test;
|
||||
select json.`a/b/c`.:Int64, json.`a-b-c`.:Int64, json.`a-b/c-d/e`.:Int64 from test;
|
||||
drop table test;
|
||||
|
Loading…
Reference in New Issue
Block a user