mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Fix tuple output in CSV format
This commit is contained in:
parent
abbab7ff87
commit
ba6a513db0
@ -260,7 +260,7 @@ void SerializationTuple::serializeTextCSV(const IColumn & column, size_t row_num
|
||||
for (const auto i : collections::range(0, elems.size()))
|
||||
{
|
||||
if (i != 0)
|
||||
writeChar(',', ostr);
|
||||
writeChar(settings.csv.tuple_delimiter, ostr);
|
||||
elems[i]->serializeTextCSV(extractElementColumn(column, i), row_num, ostr, settings);
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ void SerializationTuple::deserializeTextCSV(IColumn & column, ReadBuffer & istr,
|
||||
if (i != 0)
|
||||
{
|
||||
skipWhitespaceIfAny(istr);
|
||||
assertChar(settings.csv.delimiter, istr);
|
||||
assertChar(settings.csv.tuple_delimiter, istr);
|
||||
skipWhitespaceIfAny(istr);
|
||||
}
|
||||
elems[i]->deserializeTextCSV(extractElementColumn(column, i), istr, settings);
|
||||
|
@ -57,6 +57,7 @@ FormatSettings getFormatSettings(ContextPtr context, const Settings & settings)
|
||||
format_settings.csv.allow_single_quotes = settings.format_csv_allow_single_quotes;
|
||||
format_settings.csv.crlf_end_of_line = settings.output_format_csv_crlf_end_of_line;
|
||||
format_settings.csv.delimiter = settings.format_csv_delimiter;
|
||||
format_settings.csv.tuple_delimiter = settings.format_csv_delimiter;
|
||||
format_settings.csv.empty_as_default = settings.input_format_csv_empty_as_default;
|
||||
format_settings.csv.input_format_enum_as_number = settings.input_format_csv_enum_as_number;
|
||||
format_settings.csv.null_representation = settings.format_csv_null_representation;
|
||||
|
@ -95,6 +95,7 @@ struct FormatSettings
|
||||
bool input_format_enum_as_number = false;
|
||||
bool input_format_arrays_as_nested_csv = false;
|
||||
String null_representation = "\\N";
|
||||
char tuple_delimiter = ',';
|
||||
} csv;
|
||||
|
||||
struct Custom
|
||||
|
2
tests/queries/0_stateless/02152_csv_tuple.reference
Normal file
2
tests/queries/0_stateless/02152_csv_tuple.reference
Normal file
@ -0,0 +1,2 @@
|
||||
1 Hello [1,2,3] (2,'World',[4,5,6])
|
||||
1 Hello [1,2,3] (2,'World',[4,5,6])
|
11
tests/queries/0_stateless/02152_csv_tuple.sql
Normal file
11
tests/queries/0_stateless/02152_csv_tuple.sql
Normal file
@ -0,0 +1,11 @@
|
||||
drop table if exists test_02152;
|
||||
create table test_02152 (x UInt32, y String, z Array(UInt32), t Tuple(UInt32, String, Array(UInt32))) engine=File('CSV') settings format_csv_delimiter=';';
|
||||
insert into test_02152 select 1, 'Hello', [1,2,3], tuple(2, 'World', [4,5,6]);
|
||||
select * from test_02152;
|
||||
drop table test_02152;
|
||||
|
||||
create table test_02152 (x UInt32, y String, z Array(UInt32), t Tuple(UInt32, String, Array(UInt32))) engine=File('CustomSeparated') settings format_custom_field_delimiter='<field_delimiter>', format_custom_row_before_delimiter='<row_start>', format_custom_row_after_delimiter='<row_end_delimiter>', format_custom_escaping_rule='CSV';
|
||||
insert into test_02152 select 1, 'Hello', [1,2,3], tuple(2, 'World', [4,5,6]);
|
||||
select * from test_02152;
|
||||
drop table test_02152;
|
||||
|
Loading…
Reference in New Issue
Block a user