MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / InferTypes

Function InferTypes

pkg/sql/sem/tree/datum.go:6349–6361  ·  view source on GitHub ↗

InferTypes takes a list of strings produced by ParsePath and returns a slice of datum types inferred from the strings. Type DInt will be used if possible, otherwise DString. For example, a vals slice ["1", "foo"] will give a types slice [Dint, DString].

(vals []string)

Source from the content-addressed store, hash-verified

6347// otherwise DString. For example, a vals slice ["1", "foo"] will give a types
6348// slice [Dint, DString].
6349func InferTypes(vals []string) []types.Family {
6350 // Infer the datum types and populate typs accordingly.
6351 typs := make([]types.Family, len(vals))
6352 for i := 0; i < len(vals); i++ {
6353 typ := types.IntFamily
6354 _, err := ParseDInt(vals[i])
6355 if err != nil {
6356 typ = types.StringFamily
6357 }
6358 typs[i] = typ
6359 }
6360 return typs
6361}
6362
6363// AdjustValueToType checks that the width (for strings, byte arrays, and bit
6364// strings) and scale (decimal). and, shape/srid (for geospatial types) fits the

Callers

nothing calls this directly

Calls 1

ParseDIntFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…