You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suppose that NestedType class is not working as intended.
As I understand, it is used when Nested column is declared as a single array of tuples (flatten_nested = 0). For example:
SET flatten_nested =0;
CREATETABLETestTable
(
`_id` UUID,
`CreatedAt` DateTime DEFAULT now(),
`Comments` Nested(Id Nullable(String), Comment Nullable(String)),
)
ENGINE = ReplacingMergeTree(CreatedAt)
ORDER BY (_id, CreatedAt);
NestedType inherits TupleType and has property FrameworkType initialized with type of array of tuples. But it is implemented to read\write single tuple.
When I pass an array of tuples to WriteToServerAsync, I will receive the validation error:
Unhandled exception. ClickHouse.Client.Copy.ClickHouseBulkCopySerializationException: Error when serializing data
---> System.ArgumentException: Wrong number of elements in Tuple (Parameter 'value')
at ClickHouse.Client.Types.TupleType.Write(ExtendedBinaryWriter writer, Object value) in C:\Code\ClickHouse.Client\ClickHouse.Client\Types\TupleType.cs:line 114
at ClickHouse.Client.Copy.ClickHouseBulkCopy.SerializeBatch(Batch batch) in C:\Code\ClickHouse.Client\ClickHouse.Client\Copy\ClickHouseBulkCopy.cs:line 17
...
When I use single tuple, I will receive another error after sending batch to ClickHouse:
using(varbulkCopyInterface=newClickHouseBulkCopy(connection){ColumnNames=newstring[]{"_id","Comments"},DestinationTableName="TestTable"}){awaitbulkCopyInterface.InitAsync();awaitbulkCopyInterface.WriteToServerAsync(newList<object[]>(){newobject[]{Guid.NewGuid(),("1","Comment1")},//new object[] { Guid.NewGuid(), new ITuple[] {("1", "Comment1"),("2","Comment2"),("3","Comment3")}}});}
Unhandled exception. ClickHouse.Client.ClickHouseServerException (0x00000021): Code: 33. DB::Exception: Cannot read all data. Bytes read: 12. Bytes expected: 16.: (at row 2): While executing BinaryRowInputFormat. (CANNOT_READ_ALL_DATA) (version 22.9.2.7 (official build)) at ClickHouse.Client.ADO.ClickHouseConnection.HandleError(HttpResponseMessage response, String query, Activity activity) in C:\Code\ClickHouse.Client\ClickHouse.Client\ADO\ClickHouseConnection.cs:line 216
at ClickHouse.Client.ADO.ClickHouseConnection.PostStreamAsync(String sql, Stream data, Boolean isCompressed, CancellationToken token) in C:\Code\ClickHouse.Client\ClickHouse.Client\ADO\ClickHouseConnection.cs:line 296
at ClickHouse.Client.Copy.ClickHouseBulkCopy.SendBatchAsync(Batch batch, CancellationToken token) in C:\Code\ClickHouse.Client\ClickHouse.Client\Copy\ClickHouseBulkCopy.cs:line 193...
There are errors on reading the nested column too.
I think NestedType has to be implemented like ArrayType, with Read\Write methods overridden:
It allows to read\write nested column as array of tuples correctly:
classTestModel{publicGuid_id{get;set;}publicDateTimeCreatedAt{get;set;}publicITuple[]Comments{get;set;}}varresult=awaitconnection.QueryAsync<TestModel>("SELECT * FROM TestTable");//...awaitbulkCopyInterface.WriteToServerAsync(newList<object[]>(){newobject[]{Guid.NewGuid(),newITuple[]{("1","Comment1"),("2","Comment2"),("3","Comment3")}}});
The text was updated successfully, but these errors were encountered:
Please check behavior in version 7.3.0. The client was behaving correctly with flatten_nested = 1 (default) but did not behave correctly when flatten_nested was set to 0 for nested item insertion
Hello,
I suppose that
NestedType
class is not working as intended.As I understand, it is used when Nested column is declared as a single array of tuples (flatten_nested = 0). For example:
NestedType
inheritsTupleType
and has propertyFrameworkType
initialized with type of array of tuples. But it is implemented to read\write single tuple.When I pass an array of tuples to
WriteToServerAsync
, I will receive the validation error:When I use single tuple, I will receive another error after sending batch to ClickHouse:
There are errors on reading the nested column too.
I think
NestedType
has to be implemented likeArrayType
, with Read\Write methods overridden:It allows to read\write nested column as array of tuples correctly:
The text was updated successfully, but these errors were encountered: