ch-go icon indicating copy to clipboard operation
ch-go copied to clipboard

[QUESTION] How to call AppendKV when ColMap is wrapped in an array

Open OrangeFlag opened this issue 6 months ago • 1 comments

Hello! Thank you for the wonderful library.

Could you please help me? I want to call the method AppendKV for ColMap that is wrapped inside a ColArr. My goal is to set a specific order of keys in each of these maps.

Here is an example of what I'm trying to achieve:

eventsAttr := proto.NewArray(
  proto.NewMap[string, string](
    new(proto.ColStr).LowCardinality(),
    new(proto.ColStr),
  ),
)

eventsAttrArr := make([][]proto.KV[string, string], 0, len(events))
eventsAttrArr = append(eventsAttrArr, []proto.KV[string, string]{
  {Key: "one", Value: "specific"},
  {Key: "two", Value: "order"},
})

eventsAttrArr = append(eventsAttrArr, []proto.KV[string, string]{
  {Key: "one", Value: "totally"},
  {Key: "two", Value: "specific"},
  {Key: "three", Value: "order"},
})

// somehow add all eventsAttrArr to eventsAttr (?)

Could you provide an example of how this can be done?

Thank you in advance for your assistance!

P.S. Is it maybe possible to achieve this using *proto.ColArr[[]proto.KV]? Will it serialize correctly to Array(Map(LowCardinality(String), String))?

OrangeFlag avatar Jul 31 '24 21:07 OrangeFlag