MCPcopy Create free account
hub / github.com/brimdata/super / maybeConvertToUnion

Method maybeConvertToUnion

runtime/sam/expr/function/cast.go:191–204  ·  view source on GitHub ↗
(vals []super.Value, types map[super.Type]struct{})

Source from the content-addressed store, hash-verified

189}
190
191func (c *cast) maybeConvertToUnion(vals []super.Value, types map[super.Type]struct{}) (super.Type, bool) {
192 typesSlice := slices.Collect(maps.Keys(types))
193 if len(typesSlice) == 1 {
194 return typesSlice[0], true
195 }
196 union := c.sctx.LookupTypeUnion(typesSlice)
197 aok := true
198 for i, val := range vals {
199 var ok bool
200 vals[i], ok = c.toUnion(val, union)
201 aok = aok && ok
202 }
203 return union, aok
204}
205
206func (c *cast) toMap(from super.Value, to *super.TypeMap) (super.Value, bool) {
207 fromType, ok := from.Type().(*super.TypeMap)

Callers 2

toArrayOrSetMethod · 0.95
toMapMethod · 0.95

Calls 3

toUnionMethod · 0.95
KeysMethod · 0.80
LookupTypeUnionMethod · 0.80

Tested by

no test coverage detected