Open AdvaithD opened 8 months ago
Hi, what result do you expect? What is the definition of the table and Metadata
?
Hello, I have been trying to add metadata to rows also via #[serde(flatten)]
. The patten I would expect is as follows:
#[derive(Row, Serialize)]
struct Metadata {
foo: String,
bar: String,
}
#[derive(Row, Serialize)]
struct MyRow {
#[serde(flatten)]
metadata: Metadata,
data: String,
}
This would be expected to represent a row with columns (foo, bar, data).
I may be misunderstanding serde, but to me this seems like how the attribute should behave.
For reference I intend to use this in a templated struct to apply metadata (source/timestamp) to rows during their final submissions. But the example above is better to show the behaviour I expect.
Thanks
Edit: I realise this may be related to struct flattening, not map flattening as the issue relates, but this may be to do with terminology in serde.
I have similar issue but with deserialization for the following struct
#[derive(Debug, Row, Deserialize)]
pub(super) struct ClickhouseQueryMeterResult {
// Use ClickHouse's custom serialization for datetime fields
#[serde(with = "clickhouse::serde::time::datetime")]
pub windowstart: OffsetDateTime,
#[serde(with = "clickhouse::serde::time::datetime")]
pub windowend: OffsetDateTime,
pub value: f64,
#[serde(flatten)]
pub grouped_by: HashMap<String, Value>,
}
I want to deserialize all the additional fields returned from clickhouse into grouped_by field. Is there a work around for this ?
I encountered an issue with the
clickhouse
crate when trying to serialize a struct that uses#[serde(flatten)]
to combine multiple fields into a single row. It appears that theserialize_map
function is not implemented, as indicated by thetodo!()
macro insrc/rowbinary/ser.rs
at line 168, column 9.Example:
From the source (
src/rowbinary/ser.rs:168.9
)When attempting to serialize this struct, my binary panics because
serialize_map
is not yet supported by the crate. Is there a workaround or a planned update to support this functionality?